Skip to content

Commit 4c61683

Browse files
authored
[Fix] Reflect backend updates in state for databricks_app (#4337)
## Changes <!-- Summary of your changes that are easy to understand --> Following #4099, updates to Databricks Apps only reflected the ones in the plan, and not the ones coming back from the backend call to update the app. This PR includes those changes in. ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [ ] relevant change in `docs/` folder - [x] covered with integration tests in `internal/acceptance` - [x] using Go SDK - [x] using TF Plugin Framework Co-authored-by: Omer Lachish <[email protected]>
1 parent cc758b8 commit 4c61683

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

internal/providers/pluginfw/products/app/resource_app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ func (a *resourceApp) Update(ctx context.Context, req resource.UpdateRequest, re
159159
if resp.Diagnostics.HasError() {
160160
return
161161
}
162-
_, err := w.Apps.Update(ctx, apps.UpdateAppRequest{App: &appGoSdk, Name: app.Name.ValueString()})
162+
response, err := w.Apps.Update(ctx, apps.UpdateAppRequest{App: &appGoSdk, Name: app.Name.ValueString()})
163163
if err != nil {
164164
resp.Diagnostics.AddError("failed to update app", err.Error())
165165
return
166166
}
167167

168168
// Store the updated version of the app in state
169169
var newApp apps_tf.App
170-
resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, appGoSdk, &newApp)...)
170+
resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, response, &newApp)...)
171171
if resp.Diagnostics.HasError() {
172172
return
173173
}

internal/providers/pluginfw/products/app/resource_app_acc_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"testing"
77

88
"github.com/databricks/terraform-provider-databricks/internal/acceptance"
9+
"github.com/hashicorp/terraform-plugin-testing/terraform"
10+
"github.com/stretchr/testify/assert"
911
)
1012

1113
const baseResources = `
@@ -118,14 +120,24 @@ is required`)),
118120
}
119121

120122
func TestAccAppResource(t *testing.T) {
123+
var updateTime string
121124
acceptance.LoadWorkspaceEnv(t)
122125
if acceptance.IsGcp(t) {
123126
acceptance.Skipf(t)("not available on GCP")
124127
}
125128
acceptance.WorkspaceLevel(t, acceptance.Step{
126129
Template: makeTemplate("My app"),
130+
Check: func(s *terraform.State) error {
131+
updateTime = s.RootModule().Resources["databricks_app.this"].Primary.Attributes["update_time"]
132+
return nil
133+
},
127134
}, acceptance.Step{
128135
Template: makeTemplate("My new app"),
136+
Check: func(s *terraform.State) error {
137+
var newUpdateTime = s.RootModule().Resources["databricks_app.this"].Primary.Attributes["update_time"]
138+
assert.NotEqual(t, updateTime, newUpdateTime)
139+
return nil
140+
},
129141
}, acceptance.Step{
130142
ImportState: true,
131143
ResourceName: "databricks_app.this",

0 commit comments

Comments
 (0)