Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Jun 14, 2024
1 parent a6d7ce6 commit 513db10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
16 changes: 7 additions & 9 deletions pkg/acceptance/helpers/database_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,16 @@ func (c *DatabaseClient) CreatePrimaryDatabase(t *testing.T, enableReplicationTo
return primaryDatabase, externalPrimaryId, primaryDatabaseCleanup
}

func (c *DatabaseClient) UpdateDataRetentionTime(t *testing.T, id sdk.AccountObjectIdentifier, days int) func() {
func (c *DatabaseClient) UpdateDataRetentionTime(t *testing.T, id sdk.AccountObjectIdentifier, days int) {
t.Helper()
ctx := context.Background()

return func() {
err := c.client().Alter(ctx, id, &sdk.AlterDatabaseOptions{
Set: &sdk.DatabaseSet{
DataRetentionTimeInDays: sdk.Int(days),
},
})
require.NoError(t, err)
}
err := c.client().Alter(ctx, id, &sdk.AlterDatabaseOptions{
Set: &sdk.DatabaseSet{
DataRetentionTimeInDays: sdk.Int(days),
},
})
require.NoError(t, err)
}

func (c *DatabaseClient) UnsetCatalog(t *testing.T, id sdk.AccountObjectIdentifier) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/resources/database_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ func TestAcc_Database_IntParameter(t *testing.T) {
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
planchecks.PrintPlanDetails("snowflake_database.test", "data_retention_time_in_days"),
planchecks.ExpectChange("snowflake_database.test", "data_retention_time_in_days", tfjson.ActionNoop, sdk.String("25"), sdk.String("25")),
planchecks.ExpectDrift("snowflake_database.test", "data_retention_time_in_days", sdk.String("25"), sdk.String("50")),
planchecks.ExpectChange("snowflake_database.test", "data_retention_time_in_days", tfjson.ActionUpdate, sdk.String("50"), sdk.String("25")),
planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", false),
},
},
Expand Down Expand Up @@ -874,7 +875,7 @@ func TestAcc_Database_IntParameter(t *testing.T) {
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
planchecks.PrintPlanDetails("snowflake_database.test", "data_retention_time_in_days"),
planchecks.ExpectChange("snowflake_database.test", "data_retention_time_in_days", tfjson.ActionNoop, sdk.String("50"), sdk.String("50")),
planchecks.ExpectChange("snowflake_database.test", "data_retention_time_in_days", tfjson.ActionUpdate, sdk.String("50"), nil),
planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", false),
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/database_old_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestAcc_Database_DefaultDataRetentionTime_SetOutsideOfTerraform(t *testing.
),
},
{
PreConfig: acc.TestClient().Database.UpdateDataRetentionTime(t, id, 20),
PreConfig: func() { acc.TestClient().Database.UpdateDataRetentionTime(t, id, 20) },
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_Database_DefaultDataRetentionTime/WithoutDataRetentionSet"),
ConfigVariables: configVariablesWithoutDatabaseDataRetentionTime(),
Check: resource.ComposeTestCheckFunc(
Expand Down

0 comments on commit 513db10

Please sign in to comment.