Skip to content

Commit

Permalink
reflect backend updates in state for databricks_app
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchy committed Dec 20, 2024
1 parent 18d13bf commit 04702ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/providers/pluginfw/products/app/resource_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ func (a *resourceApp) Update(ctx context.Context, req resource.UpdateRequest, re
if resp.Diagnostics.HasError() {
return
}
_, err := w.Apps.Update(ctx, apps.UpdateAppRequest{App: &appGoSdk, Name: app.Name.ValueString()})
response, err := w.Apps.Update(ctx, apps.UpdateAppRequest{App: &appGoSdk, Name: app.Name.ValueString()})
if err != nil {
resp.Diagnostics.AddError("failed to update app", err.Error())
return
}

// Store the updated version of the app in state
var newApp apps_tf.App
resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, appGoSdk, &newApp)...)
resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, response, &newApp)...)
if resp.Diagnostics.HasError() {
return
}
Expand Down
12 changes: 12 additions & 0 deletions internal/providers/pluginfw/products/app/resource_app_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"testing"

"github.com/databricks/terraform-provider-databricks/internal/acceptance"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/stretchr/testify/assert"
)

const baseResources = `
Expand Down Expand Up @@ -118,14 +120,24 @@ is required`)),
}

func TestAccAppResource(t *testing.T) {
var updateTime string
acceptance.LoadWorkspaceEnv(t)
if acceptance.IsGcp(t) {
acceptance.Skipf(t)("not available on GCP")
}
acceptance.WorkspaceLevel(t, acceptance.Step{
Template: makeTemplate("My app"),
Check: func(s *terraform.State) error {
updateTime = s.RootModule().Resources["databricks_app.this"].Primary.Attributes["update_time"]
return nil
},
}, acceptance.Step{
Template: makeTemplate("My new app"),
Check: func(s *terraform.State) error {
var newUpdateTime = s.RootModule().Resources["databricks_app.this"].Primary.Attributes["update_time"]
assert.NotEqual(t, updateTime, newUpdateTime)
return nil
},
}, acceptance.Step{
ImportState: true,
ResourceName: "databricks_app.this",
Expand Down

0 comments on commit 04702ec

Please sign in to comment.