package docker import "path/filepath" import "testing" func TestParseV2Path(t *testing.T) { var repo string var action string var rest string repo, action, rest = parseV2Path("/v2/p/r/tags/list") if repo != "p/r" || action != "tags" || rest != "" { t.Fatalf("unexpected parse for tags: repo=%s action=%s rest=%s", repo, action, rest) } repo, action, rest = parseV2Path("/v2/p/r/manifests/latest") if repo != "p/r" || action != "manifest" || rest != "latest" { t.Fatalf("unexpected parse for manifest: repo=%s action=%s rest=%s", repo, action, rest) } } func TestIsReservedImagePath(t *testing.T) { if !IsReservedImagePath(".root") { t.Fatalf(".root must be reserved") } if IsReservedImagePath("team/app") { t.Fatalf("normal image path must not be reserved") } } func TestImagePath(t *testing.T) { var path string path = ImagePath(filepath.Join("x", "repo"), "") if path != filepath.Join("x", "repo", ".root") { t.Fatalf("unexpected root image path: %s", path) } }