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 082945a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 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
3 changes: 2 additions & 1 deletion pkg/acceptance/testenvs/testing_environment_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package testenvs

import (
"fmt"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

type env string
Expand Down
10 changes: 6 additions & 4 deletions pkg/resources/database_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package resources_test

import (
"fmt"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs"
"strconv"
"testing"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/snowflakechecks"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/importchecks"
Expand Down Expand Up @@ -755,7 +756,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,8 +876,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("50"), sdk.String("50")),
planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", false),
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", true),
},
},
Check: resource.ComposeTestCheckFunc(
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "snowflake_shared_database" "test" {
name = var.shared_database_name
name = var.shared_database_name
from_share = var.external_share_name
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "snowflake_shared_database" "test" {
name = var.shared_database_name
name = var.shared_database_name
from_share = var.external_share_name
}

Expand Down

0 comments on commit 082945a

Please sign in to comment.