Skip to content

Commit

Permalink
fix: Fix failing integration tests
Browse files Browse the repository at this point in the history
Some tests failed in
https://github.com/Snowflake-Labs/terraform-provider-snowflake/actions/runs/9187815690/job/25266290438?pr=2830.

This probably happened because more resources were returned by Show.
This change removes slice length asserts in failing tests. The asserts
are still correct because expected elements are being found and asserted.
  • Loading branch information
sfc-gh-jmichalak committed May 22, 2024
1 parent 750fe37 commit 43379a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions pkg/sdk/testint/grants_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ func TestInt_GrantAndRevokePrivilegesToAccountRole(t *testing.T) {
},
})
require.NoError(t, err)
assert.Equal(t, 1, len(grants))
assert.Equal(t, sdk.SchemaObjectPrivilegeSelect.String(), grants[0].Privilege)
assert.Equal(t, tableTest.ID().FullyQualifiedName(), grants[0].Name.FullyQualifiedName())
selectPrivilege, err := collections.FindOne[sdk.Grant](grants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectPrivilegeSelect.String() })
require.NoError(t, err)
assert.Equal(t, tableTest.ID().FullyQualifiedName(), selectPrivilege.Name.FullyQualifiedName())

// now revoke and verify that the grant(s) are gone
err = client.Grants.RevokePrivilegesFromAccountRole(ctx, privileges, on, roleTest.ID(), nil)
Expand Down Expand Up @@ -511,8 +511,6 @@ func TestInt_GrantAndRevokePrivilegesToDatabaseRole(t *testing.T) {
})
require.NoError(t, err)
// Expecting two grants because database role has usage on database by default
require.Equal(t, 2, len(returnedGrants))

usagePrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() })
require.NoError(t, err)
assert.Equal(t, sdk.ObjectTypeDatabaseRole, usagePrivilege.GrantedTo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ func TestInt_RowAccessPolicies(t *testing.T) {
returnedRowAccessPolicies, err := client.RowAccessPolicies.Show(ctx, showRequest)
require.NoError(t, err)

assert.Equal(t, 2, len(returnedRowAccessPolicies))
assert.Contains(t, returnedRowAccessPolicies, *rowAccessPolicy1)
assert.Contains(t, returnedRowAccessPolicies, *rowAccessPolicy2)
})
Expand Down

0 comments on commit 43379a7

Please sign in to comment.