-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain_test.go
40 lines (34 loc) · 904 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ecr"
)
func TestSeparateImages(t *testing.T) {
testcases := map[string]struct {
images []*ecr.ImageIdentifier
expTagsLen int
expNoTagsLen int
}{
"empty": {images: []*ecr.ImageIdentifier{},
expTagsLen: 0,
expNoTagsLen: 0,
},
"simple": {images: []*ecr.ImageIdentifier{
{ImageDigest: aws.String("foo"), ImageTag: aws.String("foo")},
{ImageDigest: aws.String("bar")},
},
expTagsLen: 1,
expNoTagsLen: 1,
},
}
for _, testcase := range testcases {
noTag, withTag := separateHavingTag(testcase.images)
if len(noTag) != testcase.expNoTagsLen {
t.Errorf("want %d with no tag got %s", testcase.expNoTagsLen, len(noTag))
}
if len(withTag) != testcase.expTagsLen {
t.Errorf("want %d with tag got %s", testcase.expTagsLen, len(withTag))
}
}
}