Skip to content

Commit

Permalink
fix: use suppressQuoting to fix stage file_format permadiff
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumelecerf committed Jun 22, 2024
1 parent b3214a1 commit 6ec9f8b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/resources/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions pkg/resources/stage_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 6ec9f8b

Please sign in to comment.