Skip to content

Commit

Permalink
Add more test steps
Browse files Browse the repository at this point in the history
References: #3007
  • Loading branch information
sfc-gh-asawicki committed Aug 28, 2024
1 parent 28aae6e commit 1f9ab46
Showing 1 changed file with 76 additions and 1 deletion.
77 changes: 76 additions & 1 deletion pkg/resources/table_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,8 @@ func TestAcc_Table_issue3007_textColumn(t *testing.T) {
name := acc.TestClient().Ids.Alpha()
resourceName := "snowflake_table.test_table"

defaultVarchar := fmt.Sprintf("VARCHAR(%d)", sdk.DefaultVarcharLength)

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
Expand All @@ -2122,10 +2124,45 @@ func TestAcc_Table_issue3007_textColumn(t *testing.T) {
},
},
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "column.0.type", "NUMBER(11,2)"),
resource.TestCheckResourceAttr(resourceName, "column.1.type", "VARCHAR(256)"),
),
},
{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
Config: tableConfigIssue3007(name, databaseName, schemaName, "VARCHAR"),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
planchecks.ExpectChange(resourceName, "column.1.type", tfjson.ActionUpdate, sdk.String("VARCHAR(256)"), sdk.String("VARCHAR")),
},
},
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "column.1.type", defaultVarchar),
),
},
{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
Config: tableConfigIssue3007(name, databaseName, schemaName, defaultVarchar),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
},
},
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "column.1.type", defaultVarchar),
),
},
{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
Config: tableConfigIssue3007(name, databaseName, schemaName, "text"),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
},
},
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "column.1.type", defaultVarchar),
),
},
},
})
}
Expand All @@ -2137,6 +2174,8 @@ func TestAcc_Table_issue3007_numberColumn(t *testing.T) {
name := acc.TestClient().Ids.Alpha()
resourceName := "snowflake_table.test_table"

defaultNumber := fmt.Sprintf("NUMBER(%d,%d)", sdk.DefaultNumberPrecision, sdk.DefaultNumberScale)

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
Expand Down Expand Up @@ -2164,6 +2203,42 @@ func TestAcc_Table_issue3007_numberColumn(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "column.1.type", "NUMBER(11,0)"),
),
},
{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
Config: tableConfigIssue3007(name, databaseName, schemaName, "NUMBER"),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
planchecks.ExpectChange(resourceName, "column.1.type", tfjson.ActionUpdate, sdk.String("NUMBER(11,0)"), sdk.String("NUMBER")),
},
},
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "column.1.type", defaultNumber),
),
},
{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
Config: tableConfigIssue3007(name, databaseName, schemaName, defaultNumber),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
},
},
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "column.1.type", defaultNumber),
),
},
{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
Config: tableConfigIssue3007(name, databaseName, schemaName, "decimal"),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
},
},
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "column.1.type", defaultNumber),
),
},
},
})
}
Expand Down

0 comments on commit 1f9ab46

Please sign in to comment.