-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(imagesset): adds tests for AddImages
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package docker | ||
|
||
import "testing" | ||
|
||
func TestImagesSet_AddImages(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
imagesAdded []map[string]interface{} | ||
imagesToAdd []map[string]interface{} | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "adds images without error", | ||
imagesAdded: []map[string]interface{}{}, | ||
imagesToAdd: []map[string]interface{}{ | ||
{"id": "1"}, | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "adds duplicated images", | ||
imagesAdded: []map[string]interface{}{ | ||
{"id": "1"}, | ||
}, | ||
imagesToAdd: []map[string]interface{}{ | ||
{"id": "1"}, | ||
}, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
imagesAdded := make([]*Image, len(tt.imagesAdded)) | ||
for i, img := range tt.imagesAdded { | ||
imagesAdded[i], _ = NewImage(img) | ||
} | ||
imagesToAdd := make([]*Image, len(tt.imagesToAdd)) | ||
for i, img := range tt.imagesToAdd { | ||
imagesToAdd[i], _ = NewImage(img) | ||
} | ||
is := NewImagesSet(imagesAdded...) | ||
if err := is.AddImages(imagesToAdd...); (err != nil) != tt.wantErr { | ||
t.Errorf("ImagesSet.AddImages() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |