Skip to content

Commit ac85124

Browse files
committed
more fixes for tests
1 parent e2edb57 commit ac85124

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

internal/providers/pluginfw/products/permissions/resource_permission.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,24 @@ func (r *PermissionResource) ImportState(ctx context.Context, req resource.Impor
565565
configuredValue := permID
566566
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root(mapping.GetField()), types.StringValue(configuredValue))...)
567567

568-
// Set principal fields
569-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_name"), types.StringValue(userName))...)
570-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("group_name"), types.StringValue(groupName))...)
571-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("service_principal_name"), types.StringValue(servicePrincipalName))...)
568+
// Set principal fields - use null for empty strings to avoid ImportStateVerify failures
569+
if userName != "" {
570+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_name"), types.StringValue(userName))...)
571+
} else {
572+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_name"), types.StringNull())...)
573+
}
574+
575+
if groupName != "" {
576+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("group_name"), types.StringValue(groupName))...)
577+
} else {
578+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("group_name"), types.StringNull())...)
579+
}
580+
581+
if servicePrincipalName != "" {
582+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("service_principal_name"), types.StringValue(servicePrincipalName))...)
583+
} else {
584+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("service_principal_name"), types.StringNull())...)
585+
}
572586

573587
// Set permission level
574588
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("permission_level"), types.StringValue(permissionLevel))...)

permissions/resource_permission_acc_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ func TestAccPermission_Authorization_Tokens(t *testing.T) {
175175
acceptance.LoadDebugEnvIfRunsFromIDE(t, "workspace")
176176
template := `
177177
resource "databricks_group" "team_a" {
178-
display_name = "permission-team-a-{var.RANDOM}"
178+
display_name = "permission-team-a-{var.STICKY_RANDOM}"
179179
}
180180
181181
resource "databricks_group" "team_b" {
182-
display_name = "permission-team-b-{var.RANDOM}"
182+
display_name = "permission-team-b-{var.STICKY_RANDOM}"
183183
}
184184
185185
resource "databricks_group" "team_c" {
186-
display_name = "permission-team-c-{var.RANDOM}"
186+
display_name = "permission-team-c-{var.STICKY_RANDOM}"
187187
}
188188
189189
# This demonstrates the key benefit: each team's token permissions
@@ -245,15 +245,15 @@ resource "databricks_permission" "tokens_team_c" {
245245
// Update one permission independently - remove team_b
246246
Template: `
247247
resource "databricks_group" "team_a" {
248-
display_name = "permission-team-a-{var.RANDOM}"
248+
display_name = "permission-team-a-{var.STICKY_RANDOM}"
249249
}
250250
251251
resource "databricks_group" "team_b" {
252-
display_name = "permission-team-b-{var.RANDOM}"
252+
display_name = "permission-team-b-{var.STICKY_RANDOM}"
253253
}
254254
255255
resource "databricks_group" "team_c" {
256-
display_name = "permission-team-c-{var.RANDOM}"
256+
display_name = "permission-team-c-{var.STICKY_RANDOM}"
257257
}
258258
259259
resource "databricks_permission" "tokens_team_a" {

0 commit comments

Comments
 (0)