Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Apr 4, 2024
1 parent f952825 commit 7661276
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pkg/architests/resources_acceptance_tests_arch_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package architests

import (
"regexp"
"testing"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/architest"
Expand All @@ -25,7 +26,7 @@ func TestArchCheck_AcceptanceTests_Resources(t *testing.T) {
})

t.Run("there are no acceptance tests in other test files in the directory", func(t *testing.T) {
otherTestFiles := resourcesFiles.Filter(architest.FileNameFilterWithExclusionsProvider(architest.TestFileRegex, architest.AcceptanceTestFileRegex))
otherTestFiles := resourcesFiles.Filter(architest.FileNameFilterWithExclusionsProvider(architest.TestFileRegex, architest.AcceptanceTestFileRegex, regexp.MustCompile("helpers_test.go")))

otherTestFiles.All(func(file *architest.File) {
file.ExportedMethods().All(func(method *architest.Method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ func TestAcc_GrantPrivilegesToDatabaseRole_ChangeWithGrantOptionsOutsideOfTerraf
CheckDestroy: testAccCheckDatabaseRolePrivilegesRevoked,
Steps: []resource.TestStep{
{
PreConfig: func() { createDatabaseRoleOutsideTerraform(t, name) },
PreConfig: func() { createDatabaseRoleOutsideTerraform(t, acc.TestDatabaseName, name) },
ConfigPlanChecks: resource.ConfigPlanChecks{
PostApplyPostRefresh: []plancheck.PlanCheck{
plancheck.ExpectEmptyPlan(),
Expand Down Expand Up @@ -1001,7 +1001,7 @@ func TestAcc_GrantPrivilegesToDatabaseRole_ChangeWithGrantOptionsOutsideOfTerraf
CheckDestroy: testAccCheckDatabaseRolePrivilegesRevoked,
Steps: []resource.TestStep{
{
PreConfig: func() { createDatabaseRoleOutsideTerraform(t, name) },
PreConfig: func() { createDatabaseRoleOutsideTerraform(t, acc.TestDatabaseName, name) },
ConfigPlanChecks: resource.ConfigPlanChecks{
PostApplyPostRefresh: []plancheck.PlanCheck{
plancheck.ExpectEmptyPlan(),
Expand Down Expand Up @@ -1031,7 +1031,6 @@ func TestAcc_GrantPrivilegesToDatabaseRole_ChangeWithGrantOptionsOutsideOfTerraf
})
}

func createDatabaseRoleOutsideTerraform(t *testing.T, name string) {
// proves https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2621 doesn't apply to this resource
func TestAcc_GrantPrivilegesToDatabaseRole_RemoveGrantedObjectOutsideTerraform(t *testing.T) {
name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
Expand Down
6 changes: 3 additions & 3 deletions pkg/resources/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,13 @@ func updateAccountParameter(t *testing.T, client *sdk.Client, parameter sdk.Acco
}
}

type PlanCheck func(ctx context.Context, req plancheck.CheckPlanRequest, resp *plancheck.CheckPlanResponse)
type planCheck func(ctx context.Context, req plancheck.CheckPlanRequest, resp *plancheck.CheckPlanResponse)

func (fn PlanCheck) CheckPlan(ctx context.Context, req plancheck.CheckPlanRequest, resp *plancheck.CheckPlanResponse) {
func (fn planCheck) CheckPlan(ctx context.Context, req plancheck.CheckPlanRequest, resp *plancheck.CheckPlanResponse) {
fn(ctx, req, resp)
}

func ExpectsCreatePlan(resourceAddress string) PlanCheck {
func expectsCreatePlan(resourceAddress string) planCheck {
return func(ctx context.Context, req plancheck.CheckPlanRequest, resp *plancheck.CheckPlanResponse) {
for _, rc := range req.Plan.ResourceChanges {
if rc.Address == resourceAddress && rc.Change != nil && slices.Contains(rc.Change.Actions, tfjson.ActionCreate) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/schema_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func TestAcc_Schema_RemoveDatabaseOutsideOfTerraform(t *testing.T) {
ExpectNonEmptyPlan: true,
RefreshPlanChecks: resource.RefreshPlanChecks{
PostRefresh: []plancheck.PlanCheck{
ExpectsCreatePlan("snowflake_schema.test"),
expectsCreatePlan("snowflake_schema.test"),
},
},
},
Expand Down

0 comments on commit 7661276

Please sign in to comment.