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 Jul 5, 2024
1 parent c4fa972 commit c218ed7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/resources/api_authentication_integration_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var apiAuthCommonSchema = map[string]*schema.Schema{
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(0),
Default: -1,
Default: IntDefault,
Description: "Specifies the default lifetime of the OAuth access token (in seconds) issued by an OAuth server.",
DiffSuppressFunc: IgnoreChangeToCurrentSnowflakeValueInDescribe("oauth_access_token_validity"),
},
Expand Down Expand Up @@ -124,7 +124,7 @@ func handleApiAuthUpdate(d *schema.ResourceData) (commonApiAuthSet, commonApiAut
}

if d.HasChange("oauth_access_token_validity") {
if v := d.Get("oauth_access_token_validity").(int); v != -1 {
if v := d.Get("oauth_access_token_validity").(int); v != IntDefault {
set.oauthAccessTokenValidity = sdk.Pointer(v)
} else {
// TODO(SNOW-1515781): use UNSET
Expand Down Expand Up @@ -185,7 +185,7 @@ func handleApiAuthCreate(d *schema.ResourceData) (commonApiAuthCreate, error) {
create.comment = sdk.Pointer(v.(string))
}

if v := d.Get("oauth_access_token_validity").(int); v != -1 {
if v := d.Get("oauth_access_token_validity").(int); v != IntDefault {
create.oauthAccessTokenValidity = sdk.Pointer(v)
}
if v, ok := d.GetOk("oauth_refresh_token_validity"); ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func ParseCommaSeparatedStringArray(value string, trimQuotes bool) []string {
for i, item := range listItems {
trimmedListItems[i] = strings.TrimSpace(item)
if trimQuotes {
trimmedListItems[i] = strings.Trim(item, "'")
trimmedListItems[i] = strings.Trim(trimmedListItems[i], "'")
}
}
return trimmedListItems
Expand Down
20 changes: 19 additions & 1 deletion pkg/sdk/parsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ func TestParseCommaSeparatedStringArray(t *testing.T) {
Value: "[one]",
Result: []string{"one"},
},
{
Name: "one element in list - with quotes",
Value: "['one']",
TrimQuotes: true,
Result: []string{"one"},
},
{
Name: "multiple elements in list - with quotes",
Value: "['one', 'two', 'three']",
TrimQuotes: true,
Result: []string{"one", "two", "three"},
},
{
Name: "multiple elements in list",
Value: "[one, two, three]",
Expand All @@ -46,7 +58,13 @@ func TestParseCommaSeparatedStringArray(t *testing.T) {
{
Name: "list without brackets",
Value: "one,two,three",
Result: []string{},
Result: []string{"one", "two", "three"},
},
{
Name: "list without brackets - with quotes",
Value: "'one','two','three'",
TrimQuotes: true,
Result: []string{"one", "two", "three"},
},
}

Expand Down

0 comments on commit c218ed7

Please sign in to comment.