Skip to content

Commit

Permalink
Fix issue #2501
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-asawicki committed Feb 15, 2024
1 parent c930330 commit 015a63f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/resources/notification_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ var notificationIntegrationSchema = map[string]*schema.Schema{
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"INBOUND", "OUTBOUND"}, true),
Description: "Direction of the cloud messaging with respect to Snowflake (required only for error notifications)",
ForceNew: true,
Deprecated: "Will be removed - it is added automatically on the SDK level.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return true
},
},
// This part of the schema is the cloudProviderParams in the Snowflake documentation and differs between vendors
"notification_provider": {
Expand Down
57 changes: 57 additions & 0 deletions pkg/resources/notification_integration_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-plugin-testing/tfversion"
)
Expand Down Expand Up @@ -220,6 +221,51 @@ func TestAcc_NotificationIntegration_PushAzure(t *testing.T) {
t.Skip("Skipping because can't be currently created. Check 'create and describe notification integration - push azure' test in the SDK.")
}

// proves issue https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2501
func TestAcc_NotificationIntegration_migrateFromVersion085(t *testing.T) {
accName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))

const gcpPubsubSubscriptionName = "projects/project-1234/subscriptions/sub2"

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(tfversion.Version1_5_0),
},
CheckDestroy: testAccCheckNotificationIntegrationDestroy,
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"snowflake": {
VersionConstraint: "=0.85.0",
Source: "Snowflake-Labs/snowflake",
},
},
Config: googleAutoConfig(accName, gcpPubsubSubscriptionName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("snowflake_notification_integration.test", "enabled", "true"),
resource.TestCheckResourceAttr("snowflake_notification_integration.test", "name", accName),
resource.TestCheckResourceAttr("snowflake_notification_integration.test", "direction", "INBOUND"),
),
},
{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
Config: googleAutoConfigWithoutDirection(accName, gcpPubsubSubscriptionName),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectEmptyPlan(),
},
},
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("snowflake_notification_integration.test", "enabled", "true"),
resource.TestCheckResourceAttr("snowflake_notification_integration.test", "name", accName),
resource.TestCheckResourceAttr("snowflake_notification_integration.test", "direction", "INBOUND"),
),
},
},
})
}

func googleAutoConfig(name string, gcpPubsubSubscriptionName string) string {
s := `
resource "snowflake_notification_integration" "test" {
Expand All @@ -232,6 +278,17 @@ resource "snowflake_notification_integration" "test" {
return fmt.Sprintf(s, name, "GCP_PUBSUB", gcpPubsubSubscriptionName)
}

func googleAutoConfigWithoutDirection(name string, gcpPubsubSubscriptionName string) string {
s := `
resource "snowflake_notification_integration" "test" {
name = "%s"
notification_provider = "%s"
gcp_pubsub_subscription_name = "%s"
}
`
return fmt.Sprintf(s, name, "GCP_PUBSUB", gcpPubsubSubscriptionName)
}

func azureAutoConfig(name string, azureStorageQueuePrimaryUri string, azureTenantId string) string {
s := `
resource "snowflake_notification_integration" "test" {
Expand Down

0 comments on commit 015a63f

Please sign in to comment.