Skip to content

Commit

Permalink
return an empty workspace config repo object instead of nil (#26421)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephybun authored Jun 24, 2024
1 parent 6102fa9 commit a8700a6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
3 changes: 2 additions & 1 deletion internal/services/synapse/synapse_workspace_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,8 @@ func expandWorkspaceRepositoryConfiguration(d *pluginsdk.ResourceData) *synapse.
}
}

return nil
// API won't clear an existing repository config with nil
return &synapse.WorkspaceRepositoryConfiguration{}
}

func expandIdentityControlSQLSettings(enabled bool) *synapse.ManagedIdentitySQLControlSettingsModel {
Expand Down
54 changes: 37 additions & 17 deletions internal/services/synapse/synapse_workspace_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ func TestAccSynapseWorkspace_azdo(t *testing.T) {
Config: r.azureDevOps(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("azure_devops_repo.0.account_name").HasValue("myorg"),
check.That(data.ResourceName).Key("azure_devops_repo.0.project_name").HasValue("myproj"),
check.That(data.ResourceName).Key("azure_devops_repo.0.repository_name").HasValue("myrepo"),
check.That(data.ResourceName).Key("azure_devops_repo.0.branch_name").HasValue("dev"),
check.That(data.ResourceName).Key("azure_devops_repo.0.root_folder").HasValue("/"),
check.That(data.ResourceName).Key("azure_devops_repo.0.tenant_id").IsEmpty(),
),
},
data.ImportStep("sql_administrator_login_password"),
{
Config: r.repoConfigRemoved(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("sql_administrator_login_password"),
})
}

Expand All @@ -138,14 +140,9 @@ func TestAccSynapseWorkspace_azdoTenant(t *testing.T) {
Config: r.azureDevOpsTenant(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("azure_devops_repo.0.account_name").HasValue("myorg"),
check.That(data.ResourceName).Key("azure_devops_repo.0.project_name").HasValue("myproj"),
check.That(data.ResourceName).Key("azure_devops_repo.0.repository_name").HasValue("myrepo"),
check.That(data.ResourceName).Key("azure_devops_repo.0.branch_name").HasValue("dev"),
check.That(data.ResourceName).Key("azure_devops_repo.0.root_folder").HasValue("/"),
check.That(data.ResourceName).Key("azure_devops_repo.0.tenant_id").Exists(),
),
},
data.ImportStep("sql_administrator_login_password"),
})
}

Expand All @@ -158,13 +155,16 @@ func TestAccSynapseWorkspace_github(t *testing.T) {
Config: r.github(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("github_repo.0.account_name").HasValue("myuser"),
check.That(data.ResourceName).Key("github_repo.0.git_url").HasValue("https://github.mydomain.com"),
check.That(data.ResourceName).Key("github_repo.0.repository_name").HasValue("myrepo"),
check.That(data.ResourceName).Key("github_repo.0.branch_name").HasValue("dev"),
check.That(data.ResourceName).Key("github_repo.0.root_folder").HasValue("/"),
),
},
data.ImportStep("sql_administrator_login_password"),
{
Config: r.repoConfigRemoved(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("sql_administrator_login_password"),
})
}

Expand Down Expand Up @@ -512,6 +512,26 @@ resource "azurerm_synapse_workspace" "test" {
`, template, data.RandomInteger)
}

func (r SynapseWorkspaceResource) repoConfigRemoved(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s
resource "azurerm_synapse_workspace" "test" {
name = "acctestsw%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.test.id
sql_administrator_login = "sqladminuser"
sql_administrator_login_password = "H@Sh1CoR3!"
identity {
type = "SystemAssigned"
}
}
`, template, data.RandomInteger)
}

func (r SynapseWorkspaceResource) azureDevOpsTenant(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
Expand Down

0 comments on commit a8700a6

Please sign in to comment.