Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jmichalak committed Nov 29, 2024
1 parent b53d7c5 commit c856aa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
18 changes: 11 additions & 7 deletions pkg/resources/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ func ignoreCaseAndTrimSpaceSuppressFunc(_, old, new string, _ *schema.ResourceDa
return strings.EqualFold(strings.TrimSpace(old), strings.TrimSpace(new))
}

func getTagObjectIdentifier(v map[string]any) sdk.ObjectIdentifier {
if _, ok := v["database"]; ok {
if _, ok := v["schema"]; ok {
return sdk.NewSchemaObjectIdentifier(v["database"].(string), v["schema"].(string), v["name"].(string))
}
return sdk.NewDatabaseObjectIdentifier(v["database"].(string), v["name"].(string))
func getTagObjectIdentifier(obj map[string]any) sdk.ObjectIdentifier {
database := obj["database"].(string)
schema := obj["schema"].(string)
name := obj["name"].(string)
switch {
case schema != "":
return sdk.NewSchemaObjectIdentifier(database, schema, name)
case database != "":
return sdk.NewDatabaseObjectIdentifier(database, name)
default:
return sdk.NewAccountObjectIdentifier(name)
}
return sdk.NewAccountObjectIdentifier(v["name"].(string))
}

func getPropertyTags(d *schema.ResourceData, key string) []sdk.TagAssociation {
Expand Down
19 changes: 1 addition & 18 deletions pkg/sdk/testint/tags_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,32 +374,15 @@ func TestInt_TagsAssociations(t *testing.T) {

t.Run("TestInt_TagAssociationForAccount", func(t *testing.T) {
id := testClientHelper().Context.CurrentAccountIdentifier(t)
// test tag sdk method
err := client.Tags.Set(ctx, sdk.NewSetTagRequest(sdk.ObjectTypeAccount, id).WithSetTags(tags))
require.NoError(t, err)

assertTagSet(id, sdk.ObjectTypeAccount)

err = client.Tags.UnsetOnCurrentAccount(ctx, sdk.NewUnsetTagOnCurrentAccountRequest().WithUnsetTags(unsetTags))
require.NoError(t, err)

assertTagUnset(id, sdk.ObjectTypeAccount)
})

t.Run("TestInt_TagAssociationForAccount", func(t *testing.T) {
id := testClientHelper().Context.CurrentAccountIdentifier(t)
err := client.Tags.Set(ctx, sdk.NewSetTagRequest(sdk.ObjectTypeAccount, id).WithSetTags(tags))
require.NoError(t, err)

returnedTagValue, err := client.SystemFunctions.GetTag(ctx, tag.ID(), id, sdk.ObjectTypeAccount)
require.NoError(t, err)
assert.Equal(t, tagValue, returnedTagValue)

err = client.Tags.Unset(ctx, sdk.NewUnsetTagRequest(sdk.ObjectTypeAccount, id).WithUnsetTags(unsetTags))
require.NoError(t, err)

_, err = client.SystemFunctions.GetTag(ctx, tag.ID(), id, sdk.ObjectTypeAccount)
require.ErrorContains(t, err, "sql: Scan error on column index 0, name \"TAG\": converting NULL to string is unsupported")
assertTagUnset(id, sdk.ObjectTypeAccount)
})

accountObjectTestCases := []struct {
Expand Down

0 comments on commit c856aa8

Please sign in to comment.