Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <[email protected]>
  • Loading branch information
cpanato committed Nov 14, 2023
1 parent 2435be2 commit 37b371c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/internal/testing/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
type MockDaemon struct {
daemon.Client
Tags []string

inspectErr error
inspectResp types.ImageInspect
inspectBody []byte
}

func (m *MockDaemon) NegotiateAPIVersion(context.Context) {}
Expand All @@ -42,3 +46,7 @@ func (m *MockDaemon) ImageTag(_ context.Context, _ string, tag string) error {
m.Tags = append(m.Tags, tag)
return nil
}

func (m *MockDaemon) ImageInspectWithRaw(_ context.Context, _ string) (types.ImageInspect, []byte, error) {
return m.inspectResp, m.inspectBody, m.inspectErr
}
8 changes: 7 additions & 1 deletion pkg/publish/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package publish_test

import (
"context"
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -63,7 +64,12 @@ func TestDaemonTags(t *testing.T) {
t.Errorf("Publish() = %v, wanted prefix %v", got, want)
}

expected := []string{"ko.local/98b8c7facdad74510a7cae0cd368eb4e:v2.0.0", "ko.local/98b8c7facdad74510a7cae0cd368eb4e:v1.2.3", "ko.local/98b8c7facdad74510a7cae0cd368eb4e:production"}
imgDigest, err := img.Digest()
if err != nil {
t.Fatalf("img.Digest() = %v", err)
}

expected := []string{fmt.Sprintf("ko.local/98b8c7facdad74510a7cae0cd368eb4e:%s", strings.Replace(imgDigest.String(), "sha256:", "", 1)), "ko.local/98b8c7facdad74510a7cae0cd368eb4e:v2.0.0", "ko.local/98b8c7facdad74510a7cae0cd368eb4e:v1.2.3", "ko.local/98b8c7facdad74510a7cae0cd368eb4e:production"}

for i, v := range expected {
if client.Tags[i] != v {
Expand Down

0 comments on commit 37b371c

Please sign in to comment.