Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmay-db committed Feb 1, 2024
1 parent 45a9901 commit 402d119
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
4 changes: 4 additions & 0 deletions catalog/resource_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func ResourceConnection() *schema.Resource {
}
}

if !d.HasChangeExcept("owner") {
return nil
}

updateConnectionRequest.Owner = ""
_, err = w.Connections.Update(ctx, updateConnectionRequest)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions catalog/resource_storage_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ func ResourceStorageCredential() *schema.Resource {
return err
}
}

if !d.HasChangeExcept("owner") {
return nil
}

update.Owner = ""
_, err = w.StorageCredentials.Update(ctx, update)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/acceptance/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func TestUcAccConnectionsResourceFullLifecycle(t *testing.T) {
Template: connectionTemplateWithOwner("test.mysql.database.azure.com", "account users"),
}, step{
Template: connectionTemplateWithOwner("test.mysql.database.aws.com", "account users"),
}, step{
Template: connectionTemplateWithOwner("test.mysql.database.aws.com", "{env.TEST_DATA_ENG_GROUP}"),
}, step{
Template: connectionTemplateWithOwner("test.mysql.database.azure.com", "{env.TEST_METASTORE_ADMIN_GROUP_NAME}"),
})
Expand Down
4 changes: 4 additions & 0 deletions internal/acceptance/external_location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func TestUcAccExternalLocationUpdate(t *testing.T) {
Template: storageCredentialTemplateWithOwner("Managed by TF -- Updated Comment", "account users") +
externalLocationTemplateWithOwner("Managed by TF -- Updated Comment", "account users") +
grantsTemplateForExternalLocation,
}, step{
Template: storageCredentialTemplateWithOwner("Managed by TF -- Updated Comment", "{env.TEST_DATA_ENG_GROUP}") +
externalLocationTemplateWithOwner("Managed by TF -- Updated Comment", "{env.TEST_DATA_ENG_GROUP}") +
grantsTemplateForExternalLocation,
}, step{
Template: storageCredentialTemplateWithOwner("Managed by TF -- Updated Comment 2", "{env.TEST_METASTORE_ADMIN_GROUP_NAME}") +
externalLocationTemplateWithOwner("Managed by TF -- Updated Comment 2", "{env.TEST_METASTORE_ADMIN_GROUP_NAME}") +
Expand Down
2 changes: 2 additions & 0 deletions internal/acceptance/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func TestUcAccSchemaUpdate(t *testing.T) {
Template: catalogTemplate + schemaTemplateWithOwner("this database is managed by terraform", "account users"),
}, step{
Template: catalogTemplate + schemaTemplateWithOwner("this database is managed by terraform -- updated comment", "account users"),
}, step{
Template: catalogTemplate + schemaTemplateWithOwner("this database is managed by terraform -- updated comment", "{env.TEST_DATA_ENG_GROUP}"),
}, step{
Template: catalogTemplate + schemaTemplateWithOwner("this database is managed by terraform -- updated comment 2", "{env.TEST_METASTORE_ADMIN_GROUP_NAME}"),
})
Expand Down
29 changes: 25 additions & 4 deletions internal/acceptance/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ func TestUcAccVolumesResourceWithoutInitialOwnerAWSFullLifecycle(t *testing.T) {
volume_type = "EXTERNAL"
storage_location = databricks_external_location.some.url
}`,
},
step{
Template: prefixTestTemplate + `
}, step{
Template: prefixTestTemplate + `
resource "databricks_volume" "this" {
name = "name-def"
comment = "comment-def"
Expand All @@ -58,7 +57,18 @@ func TestUcAccVolumesResourceWithoutInitialOwnerAWSFullLifecycle(t *testing.T) {
volume_type = "EXTERNAL"
storage_location = databricks_external_location.some.url
}`,
})
}, step{
Template: prefixTestTemplate + `
resource "databricks_volume" "this" {
name = "name-def"
comment = "comment-def"
owner = "{env.TEST_DATA_ENG_GROUP}"
catalog_name = "main"
schema_name = databricks_schema.this.name
volume_type = "EXTERNAL"
storage_location = databricks_external_location.some.url
}`,
})
}

func TestUcAccVolumesResourceWithInitialOwnerAWSFullLifecycle(t *testing.T) {
Expand All @@ -84,5 +94,16 @@ func TestUcAccVolumesResourceWithInitialOwnerAWSFullLifecycle(t *testing.T) {
volume_type = "EXTERNAL"
storage_location = databricks_external_location.some.url
}`,
}, step{
Template: prefixTestTemplate + `
resource "databricks_volume" "this" {
name = "name-def"
comment = "comment-def"
owner = "{env.TEST_DATA_ENG_GROUP}"
catalog_name = "main"
schema_name = databricks_schema.this.name
volume_type = "EXTERNAL"
storage_location = databricks_external_location.some.url
}`,
})
}

0 comments on commit 402d119

Please sign in to comment.