fix compiler unit tests, hook up daemon

This commit is contained in:
Brad Rydzewski
2019-10-22 23:13:40 -07:00
parent 22e660dda7
commit 09f19e5b99
28 changed files with 1694 additions and 791 deletions

View File

@@ -4,7 +4,11 @@
package image
import "github.com/docker/distribution/reference"
import (
"strings"
"github.com/docker/distribution/reference"
)
// Trim returns the short image name without tag.
func Trim(name string) string {
@@ -69,3 +73,9 @@ func MatchHostname(image, hostname string) bool {
}
return reference.Domain(named) == hostname
}
// IsLatest parses the image and returns true if
// the image uses the :latest tag.
func IsLatest(s string) bool {
return strings.HasSuffix(Expand(s), ":latest")
}

View File

@@ -297,3 +297,41 @@ func Test_matchTag(t *testing.T) {
}
}
}
func Test_isLatest(t *testing.T) {
testdata := []struct {
name string
want bool
}{
{
name: "golang:1",
want: false,
},
{
name: "golang",
want: true,
},
{
name: "golang:latest",
want: true,
},
{
name: "docker.io/library/golang",
want: true,
},
{
name: "docker.io/library/golang:latest",
want: true,
},
{
name: "docker.io/library/golang:1",
want: false,
},
}
for _, test := range testdata {
got, want := IsLatest(test.name), test.want
if got != want {
t.Errorf("Want image %q isLatest %v", test.name, want)
}
}
}