Skip to content

Commit

Permalink
fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nfx committed Feb 16, 2023
1 parent 9f89e32 commit f8171b4
Show file tree
Hide file tree
Showing 33 changed files with 65 additions and 105 deletions.
70 changes: 11 additions & 59 deletions common/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ func TestDatabricksClientConfigure_Nothing(t *testing.T) {
DatabricksClient: &client.DatabricksClient{
Config: &config.Config{},
},
},
"authentication is not configured for provider")
}, "default auth: cannot configure default credentials")
}

func TestDatabricksClientConfigure_BasicAuth_NoHost(t *testing.T) {
Expand All @@ -52,7 +51,7 @@ func TestDatabricksClientConfigure_BasicAuth_NoHost(t *testing.T) {
Password: "bar",
},
},
}, "authentication is not configured for provider.")
}, "default auth: cannot configure default credentials")
}

func TestDatabricksClientConfigure_BasicAuth(t *testing.T) {
Expand Down Expand Up @@ -92,7 +91,7 @@ func TestDatabricksClientConfigure_Token_NoHost(t *testing.T) {
Token: "dapi345678",
},
},
}, "authentication is not configured for provider.")
}, "default auth: cannot configure default credentials")
}

func TestDatabricksClientConfigure_HostTokensTakePrecedence(t *testing.T) {
Expand Down Expand Up @@ -135,7 +134,7 @@ func TestDatabricksClientConfigure_ConfigRead(t *testing.T) {
},
})
assert.NoError(t, err)
assert.Equal(t, "databricks-cli", dc.Config.AuthType)
assert.Equal(t, "pat", dc.Config.AuthType)
assert.Equal(t, "PT0+IC9kZXYvdXJhbmRvbSA8PT0KYFZ", dc.Config.Token)
}

Expand All @@ -148,8 +147,8 @@ func TestDatabricksClientConfigure_NoHostGivesError(t *testing.T) {
Profile: "nohost",
},
},
}, "cannot configure databricks-cli auth: config file "+
"testdata/.databrickscfg is corrupt: cannot find host in nohost profile.")
}, "default auth: cannot configure default credentials. "+
"Config: token=***, profile=nohost, config_file=testdata/.databrickscfg")
}

func TestDatabricksClientConfigure_NoTokenGivesError(t *testing.T) {
Expand All @@ -174,8 +173,8 @@ func TestDatabricksClientConfigure_InvalidProfileGivesError(t *testing.T) {
Profile: "invalidhost",
},
},
}, "cannot configure databricks-cli auth: testdata/.databrickscfg "+
"has no invalidhost profile configured")
}, "resolve: testdata/.databrickscfg has no invalidhost profile configured. "+
"Config: token=***, profile=invalidhost, config_file=testdata/.databrickscfg")
}

func TestDatabricksClientConfigure_MissingFile(t *testing.T) {
Expand All @@ -187,7 +186,7 @@ func TestDatabricksClientConfigure_MissingFile(t *testing.T) {
Profile: "invalidhost",
},
},
}, "authentication is not configured for provider.")
}, "default auth: cannot configure default credentials.")
}

func TestDatabricksClientConfigure_InvalidConfigFilePath(t *testing.T) {
Expand All @@ -199,7 +198,7 @@ func TestDatabricksClientConfigure_InvalidConfigFilePath(t *testing.T) {
Profile: "invalidhost",
},
},
}, "cannot configure databricks-cli auth: cannot parse config file")
}, `resolve: cannot parse config file`)
}

func TestDatabricksClient_FormatURL(t *testing.T) {
Expand Down Expand Up @@ -312,7 +311,7 @@ func TestDatabricksClientConfigure_NonsenseAuth(t *testing.T) {
AuthType: "nonsense",
},
},
}, "cannot configure nonsense auth.")
}, "default auth: cannot configure default credentials")
}

func TestConfigAttributeSetNonsense(t *testing.T) {
Expand All @@ -321,50 +320,3 @@ func TestConfigAttributeSetNonsense(t *testing.T) {
}).Set(&DatabricksClient{}, 1)
assert.EqualError(t, err, "cannot set of unknown type Chan")
}

func TestDatabricksClientFixHost(t *testing.T) {
hostForInput := func(in string) (string, error) {
client := &DatabricksClient{
DatabricksClient: &client.DatabricksClient{
Config: &config.Config{
Host: in,
},
},
}
return client.Config.Host, nil
}

{
// Strip trailing slash.
out, err := hostForInput("https://accounts.gcp.databricks.com/")
assert.Nil(t, err)
assert.Equal(t, out, "https://accounts.gcp.databricks.com")
}

{
// Keep port.
out, err := hostForInput("https://accounts.gcp.databricks.com:443")
assert.Nil(t, err)
assert.Equal(t, out, "https://accounts.gcp.databricks.com:443")
}

{
// Default scheme.
out, err := hostForInput("accounts.gcp.databricks.com")
assert.Nil(t, err)
assert.Equal(t, out, "https://accounts.gcp.databricks.com")
}

{
// Default scheme with port.
out, err := hostForInput("accounts.gcp.databricks.com:443")
assert.Nil(t, err)
assert.Equal(t, out, "https://accounts.gcp.databricks.com:443")
}

{
// Return error.
_, err := hostForInput("://@@@accounts.gcp.databricks.com/")
assert.NotNil(t, err)
}
}
2 changes: 1 addition & 1 deletion docs/data-sources/catalogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Unity Catalog"
---
# databricks_catalogs Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves a list of [databricks_catalog](../resources/catalog.md) ids, that were created by Terraform or manually, so that special handling could be applied.

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Compute"
---
# databricks_cluster Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves information about a [databricks_cluster](../resources/cluster.md) using its id. This could be retrieved programmatically using [databricks_clusters](../data-sources/clusters.md) data source.

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/cluster_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ subcategory: "Compute"

# databricks_cluster_policy Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves information about [databricks_cluster_policy](../resources/cluster_policy.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Compute"
---
# databricks_clusters Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves a list of [databricks_cluster](../resources/cluster.md#cluster_id) ids, that were created by Terraform or manually, with or without [databricks_cluster_policy](../resources/cluster_policy.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/current_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Security"
---
# databricks_current_user Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves information about [databricks_user](../resources/user.md) or [databricks_service_principal](../resources/service_principal.md), that is calling Databricks REST API. Might be useful in applying the same Terraform by different users in the shared workspace for testing purposes.

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/dbfs_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Storage"
---
# databricks_dbfs_file Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

This data source allows to get file content from [Databricks File System (DBFS)](https://docs.databricks.com/data/databricks-file-system.html).

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/dbfs_file_paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Storage"
---
# databricks_dbfs_file_paths Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

This data source allows to get list of file names from get file content from [Databricks File System (DBFS)](https://docs.databricks.com/data/databricks-file-system.html).

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Workspace"
---
# databricks_directory Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

This data source allows to get information about a directory in a Databricks Workspace.

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Security"
---
# databricks_group Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves information about [databricks_group](../resources/group.md) members, entitlements and instance profiles.

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/instance_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ subcategory: "Compute"

# databricks_instance_pool Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves information about [databricks_instance_pool](../resources/instance_pool.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/job.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Compute"
---
# databricks_job Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves the settings of [databricks_job](../resources/job.md) by name or by id. Complements the feature of the [databricks_jobs](jobs.md) data source.

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Compute"
---
# databricks_jobs Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md) or [azurerm_databricks_workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Retrieves a list of [databricks_job](../resources/job.md) ids, that were created by Terraform or manually, so that special handling could be applied.

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/mws_credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "AWS"
---
# databricks_mws_credentials Data Source

-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _authentication is not configured for provider_ errors.
-> **Note** If you have a fully automated setup with workspaces created by [databricks_mws_workspaces](../resources/mws_workspaces.md), please make sure to add [depends_on attribute](../index.md#data-resources-and-authentication-is-not-configured-errors) in order to prevent _default auth: cannot configure default credentials_ errors.

Lists all [databricks_mws_credentials](../resources/mws_credentials.md) in Databricks Account.

Expand Down
Loading

0 comments on commit f8171b4

Please sign in to comment.