(t *testing.T)
| 63 | } |
| 64 | |
| 65 | func TestNormalizeName(t *testing.T) { |
| 66 | const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" |
| 67 | |
| 68 | for _, c := range []struct{ input, expected string }{ |
| 69 | {"#", ""}, // Clearly invalid |
| 70 | {"example.com/busybox", "example.com/busybox:latest"}, // Qualified name-only |
| 71 | {"example.com/busybox:notlatest", "example.com/busybox:notlatest"}, // Qualified name:tag |
| 72 | {"example.com/busybox" + digestSuffix, "example.com/busybox" + digestSuffix}, // Qualified name@digest |
| 73 | {"example.com/busybox:notlatest" + digestSuffix, "example.com/busybox" + digestSuffix}, // Qualified name:tag@digest |
| 74 | {"busybox:latest", "localhost/busybox:latest"}, // Unqualified name-only |
| 75 | {"busybox:latest" + digestSuffix, "localhost/busybox" + digestSuffix}, // Unqualified name:tag@digest |
| 76 | {"localhost/busybox", "localhost/busybox:latest"}, // Qualified with localhost |
| 77 | {"ns/busybox:latest", "localhost/ns/busybox:latest"}, // Unqualified with a dot-less namespace |
| 78 | {"docker.io/busybox:latest", "docker.io/library/busybox:latest"}, // docker.io without /library/ |
| 79 | } { |
| 80 | res, err := NormalizeName(c.input) |
| 81 | if c.expected == "" { |
| 82 | assert.Error(t, err, c.input) |
| 83 | } else { |
| 84 | require.NoError(t, err, c.input) |
| 85 | assert.Equal(t, c.expected, res.String()) |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | func TestNormalizeTaggedDigestedString(t *testing.T) { |
| 91 | const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" |
nothing calls this directly
no test coverage detected
searching dependent graphs…