Skip to content

Commit

Permalink
added test to demonstrate error for invalid config file path, and exp…
Browse files Browse the repository at this point in the history
…anded the bit.ly links
  • Loading branch information
stikkireddy committed Jun 10, 2020
1 parent 9df28e9 commit 887efbe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions databricks/provider.go
Expand Up @@ -89,7 +89,7 @@ func Provider(version string) terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_CONFIG_FILE", "~/.databrickscfg"),
Description: "Location of the Databricks CLI credentials file, that is created\n" +
"by `databricks configure --token` command. By default, it is located\n" +
"in ~/.databrickscfg. Check https://bit.ly/2XCtuZU for docs. Config\n" +
"in ~/.databrickscfg. Check https://docs.databricks.com/dev-tools/cli/index.html#set-up-authentication for docs. Config\n" +
"file credetials will only be used when host/token are not provided.",
},
"profile": &schema.Schema{
Expand Down Expand Up @@ -258,7 +258,7 @@ func tryDatabricksCliConfigFile(d *schema.ResourceData, config *service.DBApiCli
"1. DATABRICKS_HOST + DATABRICKS_TOKEN environment variables.\n"+
"2. host + token provider arguments.\n"+
"3. Run `databricks configure --token` that will create %s file.\n\n"+
"Please check https://bit.ly/2XCtuZU for details", configFile)
"Please check https://docs.databricks.com/dev-tools/cli/index.html#set-up-authentication for details", configFile)
}
if profile, ok := d.GetOk("profile"); ok {
dbcliConfig := cfg.Section(profile.(string))
Expand Down
11 changes: 10 additions & 1 deletion databricks/provider_test.go
Expand Up @@ -163,7 +163,16 @@ func TestProvider_InvalidProfileGivesError(t *testing.T) {
assert.NotNil(t, err)
}

func TestDatabricksCliConfigWorks(t *testing.T) {
func TestProvider_InvalidConfigFilePath(t *testing.T) {
var raw = make(map[string]interface{})
raw["config_file"] = "testdata/.invalid file"
raw["profile"] = "invalidhost"
err := testAccProvider.Configure(terraform.NewResourceConfigRaw(raw))
log.Println(err)
assert.NotNil(t, err)
}

func TestAccDatabricksCliConfigWorks(t *testing.T) {
resource.Test(t,
resource.TestCase{
Providers: testAccProviders,
Expand Down

0 comments on commit 887efbe

Please sign in to comment.