Skip to content

Commit

Permalink
Unit tests, go mod tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Aug 10, 2023
1 parent c51ef98 commit 6e55206
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8
github.com/aws/aws-sdk-go v1.44.318
github.com/aws/aws-sdk-go v1.44.320
github.com/aws/aws-sdk-go-v2 v1.20.1
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.20.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aws/aws-sdk-go v1.44.318 h1:Yl66rpbQHFUbxe9JBKLcvOvRivhVgP6+zH0b9KzARX8=
github.com/aws/aws-sdk-go v1.44.318/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.44.320 h1:o2cno15HVUYj+IAgZHJ5No6ifAxwa2HcluzahMEPfOw=
github.com/aws/aws-sdk-go v1.44.320/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v1.20.0/go.mod h1:uWOr0m0jDsiWw8nnXiqZ+YG6LdvAlGYDLLf2NmHZoy4=
github.com/aws/aws-sdk-go-v2 v1.20.1 h1:rZBf5DWr7YGrnlTK4kgDQGn1ltqOg5orCYb/UhOFZkg=
github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac=
Expand Down
2 changes: 1 addition & 1 deletion internal/flex/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ExpandStringList(configured []interface{}) []*string {
}

// ExpandStringListEmpty the result of flatmap. Expand for an array of strings
// and returns a []*string. Empty strings are NOT skipped.
// and returns a []*string. Adds an empty element for every nil or uncastable.
func ExpandStringListEmpty(configured []interface{}) []*string {
vs := make([]*string, 0, len(configured))
for _, v := range configured {
Expand Down
31 changes: 31 additions & 0 deletions internal/flex/flex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,37 @@ func TestExpandStringList(t *testing.T) {
}
}

func TestExpandStringListEmpty(t *testing.T) {
t.Parallel()

testCases := []struct {
configured []interface{}
want []*string
}{
{
configured: []interface{}{"abc", "xyz123"},
want: []*string{aws.String("abc"), aws.String("xyz123")},
},
{
configured: []interface{}{"abc", 123, "xyz123"},
want: []*string{aws.String("abc"), aws.String(""), aws.String("xyz123")},
},
{
configured: []interface{}{"foo", "bar", "", "baz"},
want: []*string{aws.String("foo"), aws.String("bar"), aws.String(""), aws.String("baz")},
},
{
configured: []interface{}{"foo", "bar", nil, "baz"},
want: []*string{aws.String("foo"), aws.String("bar"), aws.String(""), aws.String("baz")},
},
}
for _, testCase := range testCases {
if got, want := ExpandStringListEmpty(testCase.configured), testCase.want; !cmp.Equal(got, want) {
t.Errorf("ExpandStringListEmpty(%v) = %v, want %v", testCase.configured, got, want)
}
}
}

func TestExpandStringTimeList(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 6e55206

Please sign in to comment.