clair/cmd/clairctl/dockerdist/push_test.go

29 lines
857 B
Go
Raw Normal View History

2016-06-08 16:52:15 +00:00
package dockerdist
import "testing"
func TestInsertRegistryMapping(t *testing.T) {
layerID := "sha256:13be4a52fdee2f6c44948b99b5b65ec703b1ca76c1ab5d2d90ae9bf18347082e"
registryURI := "registry:5000"
2016-05-02 19:47:14 +00:00
insertRegistryMapping(layerID, registryURI)
if r := registryMapping[layerID]; r != registryURI {
2016-05-02 19:47:14 +00:00
t.Errorf("insertRegistryMapping(%q,%q) => %q, want %q", layerID, registryURI, r, registryURI)
}
}
func TestGetRegistryMapping(t *testing.T) {
layerID := "sha256:13be4a52fdee2f6c44948b99b5b65ec703b1ca76c1ab5d2d90ae9bf18347082e"
registryURI := "registry:5000"
2016-05-02 19:47:14 +00:00
insertRegistryMapping(layerID, registryURI)
if r, err := GetRegistryMapping(layerID); r != registryURI {
if err != nil {
2016-05-02 19:47:14 +00:00
t.Errorf("GetRegistryMapping(%q) failed => %v", layerID, err)
} else {
2016-05-02 19:47:14 +00:00
t.Errorf("GetRegistryMapping(%q) => %q, want %q", layerID, registryURI, r)
}
}
}