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 c2d6fa7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
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 c2d6fa7

Please sign in to comment.