|
1 | 1 | package catalog_test |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "context" |
5 | 4 | "fmt" |
6 | 5 | "regexp" |
7 | | - "strings" |
8 | 6 | "testing" |
9 | 7 |
|
10 | 8 | "github.com/databricks/terraform-provider-databricks/internal/acceptance" |
11 | 9 | "github.com/databricks/terraform-provider-databricks/qa" |
12 | | - tfjson "github.com/hashicorp/terraform-json" |
13 | 10 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
14 | 11 | "github.com/hashicorp/terraform-plugin-testing/plancheck" |
15 | 12 | ) |
@@ -62,35 +59,6 @@ func TestUcAccCatalogIsolated(t *testing.T) { |
62 | 59 | }) |
63 | 60 | } |
64 | 61 |
|
65 | | -type checkResourceRecreate struct { |
66 | | - address string |
67 | | -} |
68 | | - |
69 | | -func (c checkResourceRecreate) CheckPlan(ctx context.Context, req plancheck.CheckPlanRequest, resp *plancheck.CheckPlanResponse) { |
70 | | - var change *tfjson.ResourceChange |
71 | | - for _, resourceChange := range req.Plan.ResourceChanges { |
72 | | - if resourceChange.Address == c.address { |
73 | | - change = resourceChange |
74 | | - break |
75 | | - } |
76 | | - } |
77 | | - if change == nil { |
78 | | - addressesWithPlannedChanges := make([]string, 0, len(req.Plan.ResourceChanges)) |
79 | | - for _, change := range req.Plan.ResourceChanges { |
80 | | - addressesWithPlannedChanges = append(addressesWithPlannedChanges, change.Address) |
81 | | - } |
82 | | - resp.Error = fmt.Errorf("address %s not found in resource changes; only planned changes for addresses %s", c.address, strings.Join(addressesWithPlannedChanges, ", ")) |
83 | | - return |
84 | | - } |
85 | | - if change.Change.Actions[0] != tfjson.ActionDelete { |
86 | | - plannedActions := make([]string, 0, len(change.Change.Actions)) |
87 | | - for _, action := range change.Change.Actions { |
88 | | - plannedActions = append(plannedActions, string(action)) |
89 | | - } |
90 | | - resp.Error = fmt.Errorf("no delete is planned for %s; planned actions are: %s", c.address, strings.Join(plannedActions, ", ")) |
91 | | - } |
92 | | -} |
93 | | - |
94 | 62 | func TestUcAccCatalogUpdate(t *testing.T) { |
95 | 63 | acceptance.LoadUcwsEnv(t) |
96 | 64 | acceptance.UnityWorkspaceLevel(t, acceptance.Step{ |
@@ -153,7 +121,7 @@ func TestUcAccCatalogUpdate(t *testing.T) { |
153 | 121 | }`, getPredictiveOptimizationSetting(t, false)), |
154 | 122 | ConfigPlanChecks: resource.ConfigPlanChecks{ |
155 | 123 | PreApply: []plancheck.PlanCheck{ |
156 | | - checkResourceRecreate{address: "databricks_catalog.sandbox"}, |
| 124 | + plancheck.ExpectResourceAction("databricks_catalog.sandbox", plancheck.ResourceActionDestroyBeforeCreate), |
157 | 125 | }, |
158 | 126 | }, |
159 | 127 | }) |
|
0 commit comments