Skip to content

Commit 881e16e

Browse files
committed
fix tests
1 parent ece8e8c commit 881e16e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pkg/v1/daemon/image_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424
"strings"
2525
"testing"
2626

27+
"github.com/docker/docker/api/types"
2728
"github.com/google/go-containerregistry/internal/compare"
2829
"github.com/google/go-containerregistry/pkg/name"
29-
3030
"github.com/google/go-containerregistry/pkg/v1/tarball"
3131
)
3232

@@ -62,6 +62,12 @@ func (m *MockClient) ImageSave(_ context.Context, _ []string) (io.ReadCloser, er
6262
return m.saveBody, m.saveErr
6363
}
6464

65+
func (m *MockClient) ImageInspectWithRaw(context.Context, string) (types.ImageInspect, []byte, error) {
66+
return types.ImageInspect{
67+
ID: "sha256:6e0b05049ed9c17d02e1a55e80d6599dbfcce7f4f4b022e3c673e685789c470e",
68+
}, nil, nil
69+
}
70+
6571
func TestImage(t *testing.T) {
6672
for _, tc := range []struct {
6773
name string
@@ -114,8 +120,13 @@ func TestImage(t *testing.T) {
114120
}
115121
return
116122
}
117-
if err := compare.Images(img, dmn); err != nil {
118-
t.Errorf("compare.Images: %v", err)
123+
err = compare.Images(img, dmn)
124+
if err != nil {
125+
if tc.wantErr == "" {
126+
t.Errorf("compare.Images: %v", err)
127+
} else if !strings.Contains(err.Error(), tc.wantErr) {
128+
t.Errorf("wanted %s to contain %s", err.Error(), tc.wantErr)
129+
}
119130
}
120131
}
121132

0 commit comments

Comments
 (0)