Skip to content

Commit

Permalink
Better mock for docker.ImageID
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Jul 12, 2019
1 parent b3e079d commit f432fa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/docker/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestImageID(t *testing.T) {
{
description: "not found",
ref: "somethingelse",
shouldErr: true,
expected: "",
},
}
for _, test := range tests {
Expand Down
10 changes: 9 additions & 1 deletion testutil/fake_image_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ type FakeAPIClient struct {
PushedImages []string
}

type notFoundError struct {
error
}

func (e notFoundError) NotFound() bool {
return true
}

type errReader struct{}

func (f errReader) Read([]byte) (int, error) { return 0, fmt.Errorf("") }
Expand Down Expand Up @@ -95,7 +103,7 @@ func (f *FakeAPIClient) ImageInspectWithRaw(_ context.Context, ref string) (type

id, ok := f.TagToImageID[ref]
if !ok {
return types.ImageInspect{}, nil, fmt.Errorf("")
return types.ImageInspect{}, nil, &notFoundError{}
}

rawConfig := []byte(fmt.Sprintf(`{"Config":{"Image":"%s"}}`, id))
Expand Down

0 comments on commit f432fa8

Please sign in to comment.