From 6ec9f8b5e36689fde1a2c3d17b9c0415d7ce27b1 Mon Sep 17 00:00:00 2001 From: Guillaume Lecerf Date: Fri, 21 Jun 2024 17:09:43 +0200 Subject: [PATCH] fix: use suppressQuoting to fix stage file_format permadiff --- pkg/resources/stage.go | 7 ++++--- pkg/resources/stage_acceptance_test.go | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pkg/resources/stage.go b/pkg/resources/stage.go index 8dbb0c0806..884ca76d79 100644 --- a/pkg/resources/stage.go +++ b/pkg/resources/stage.go @@ -50,9 +50,10 @@ var stageSchema = map[string]*schema.Schema{ Description: "Specifies the name of the storage integration used to delegate authentication responsibility for external cloud storage to a Snowflake identity and access management (IAM) entity.", }, "file_format": { - Type: schema.TypeString, - Optional: true, - Description: "Specifies the file format for the stage.", + Type: schema.TypeString, + Optional: true, + Description: "Specifies the file format for the stage.", + DiffSuppressFunc: suppressQuoting, }, "copy_options": { Type: schema.TypeString, diff --git a/pkg/resources/stage_acceptance_test.go b/pkg/resources/stage_acceptance_test.go index c6f97e53f2..58ac1ff4b8 100644 --- a/pkg/resources/stage_acceptance_test.go +++ b/pkg/resources/stage_acceptance_test.go @@ -64,6 +64,7 @@ func TestAcc_Stage_CreateAndAlter(t *testing.T) { changedStorageIntegration := ids.PrecreatedS3StorageIntegration changedEncryption := "TYPE = 'AWS_SSE_S3'" changedFileFormat := "TYPE = JSON NULL_IF = []" + changedFileFormatWithQuotes := "FIELD_DELIMITER = '|' PARSE_HEADER = true" changedComment := random.Comment() copyOptionsWithoutQuotes := "ON_ERROR = CONTINUE" @@ -129,6 +130,25 @@ func TestAcc_Stage_CreateAndAlter(t *testing.T) { PostApplyPreRefresh: []plancheck.PlanCheck{plancheck.ExpectEmptyPlan()}, }, }, + { + ConfigDirectory: config.TestNameDirectory(), + ConfigVariables: configVariables(changedUrl, changedStorageIntegration.Name(), credentials, changedEncryption, changedFileFormatWithQuotes, changedComment, copyOptionsWithoutQuotes), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "database", databaseName), + resource.TestCheckResourceAttr(resourceName, "schema", schemaName), + resource.TestCheckResourceAttr(resourceName, "name", name), + resource.TestCheckResourceAttr(resourceName, "storage_integration", changedStorageIntegration.Name()), + resource.TestCheckResourceAttr(resourceName, "credentials", credentials), + resource.TestCheckResourceAttr(resourceName, "encryption", changedEncryption), + resource.TestCheckResourceAttr(resourceName, "file_format", changedFileFormatWithQuotes), + resource.TestCheckResourceAttr(resourceName, "copy_options", copyOptionsWithoutQuotes), + resource.TestCheckResourceAttr(resourceName, "url", changedUrl), + resource.TestCheckResourceAttr(resourceName, "comment", changedComment), + ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PostApplyPreRefresh: []plancheck.PlanCheck{plancheck.ExpectEmptyPlan()}, + }, + }, { ConfigDirectory: config.TestNameDirectory(), ConfigVariables: configVariables(changedUrl, changedStorageIntegration.Name(), credentials, changedEncryption, changedFileFormat, changedComment, copyOptionsWithoutQuotes),