fix compiler unit tests, hook up daemon
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user