Skip to content

Commit

Permalink
Prepare test to check issue #2528
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-asawicki committed Feb 20, 2024
1 parent f9ceb20 commit 9ccb790
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions pkg/resources/external_function_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,44 @@ func TestAcc_ExternalFunction_migrateFromVersion085(t *testing.T) {
})
}

func TestAcc_ExternalFunction_issue2528(t *testing.T) {
accName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))

resourceName := "snowflake_external_function.f"

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(tfversion.Version1_5_0),
},
CheckDestroy: nil,
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"snowflake": {
VersionConstraint: "=0.86.0",
Source: "Snowflake-Labs/snowflake",
},
},
Config: externalFunctionConfigIssue2528(acc.TestDatabaseName, acc.TestSchemaName, accName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", accName),
resource.TestCheckResourceAttr(resourceName, "database", acc.TestDatabaseName),
resource.TestCheckResourceAttr(resourceName, "schema", acc.TestSchemaName),
resource.TestCheckResourceAttr(resourceName, "arg.#", "1"),
resource.TestCheckResourceAttr(resourceName, "arg.0.name", "SNS_NOTIF"),
resource.TestCheckResourceAttr(resourceName, "arg.0.type", "OBJECT"),
resource.TestCheckResourceAttr(resourceName, "return_type", "VARIANT"),
resource.TestCheckResourceAttr(resourceName, "return_behavior", "VOLATILE"),
resource.TestCheckResourceAttrSet(resourceName, "api_integration"),
resource.TestCheckResourceAttr(resourceName, "url_of_proxy_and_resource", "https://123456.execute-api.us-west-2.amazonaws.com/prod/test_func"),
resource.TestCheckResourceAttrSet(resourceName, "created_on"),
),
},
},
})
}

func externalFunctionConfig(database string, schema string, name string) string {
return fmt.Sprintf(`
resource "snowflake_api_integration" "test_api_int" {
Expand Down Expand Up @@ -313,3 +351,29 @@ resource "snowflake_external_function" "f" {
`, database, schema, name)
}

func externalFunctionConfigIssue2528(database string, schema string, name string) string {
return fmt.Sprintf(`
resource "snowflake_api_integration" "test_api_int" {
name = "%[3]s"
api_provider = "aws_api_gateway"
api_aws_role_arn = "arn:aws:iam::000000000001:/role/test"
api_allowed_prefixes = ["https://123456.execute-api.us-west-2.amazonaws.com/prod/"]
enabled = true
}
resource "snowflake_external_function" "f" {
name = "%[3]s"
database = "%[1]s"
schema = "%[2]s"
arg {
name = "SNS_NOTIF"
type = "OBJECT"
}
return_type = "VARIANT"
return_behavior = "VOLATILE"
api_integration = snowflake_api_integration.test_api_int.name
url_of_proxy_and_resource = "https://123456.execute-api.us-west-2.amazonaws.com/prod/test_func"
}
`, database, schema, name)
}

0 comments on commit 9ccb790

Please sign in to comment.