NewImage, NewImageSource, NewImageDestination, DeleteImage tested in storage_test.go
(t *testing.T)
| 151 | // NewImage, NewImageSource, NewImageDestination, DeleteImage tested in storage_test.go |
| 152 | |
| 153 | func TestResolveReference(t *testing.T) { |
| 154 | // This is, so far, only a minimal smoke test |
| 155 | |
| 156 | ensureTestCanCreateImages(t) |
| 157 | |
| 158 | store := newStore(t) |
| 159 | storeSpec := storeSpecForStringWithinTransport(store) |
| 160 | cache := memory.New() |
| 161 | |
| 162 | id := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 163 | |
| 164 | // Create an image with a known name and ID |
| 165 | ref, err := Transport.ParseStoreReference(store, "test@"+id) |
| 166 | require.NoError(t, err) |
| 167 | createImage(t, ref, cache, []testBlob{makeLayer(t, archive.Gzip)}, nil) |
| 168 | |
| 169 | for _, c := range []struct { |
| 170 | input string |
| 171 | expected string // "" on error |
| 172 | }{ |
| 173 | { // No ID match |
| 174 | "@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "", |
| 175 | }, |
| 176 | {"@" + id, "@" + id}, // ID-only lookup |
| 177 | {"test", "docker.io/library/test:latest@" + id}, // Name is resolved to include ID |
| 178 | {"nottest", ""}, // No name match |
| 179 | {"test@" + id, "docker.io/library/test:latest@" + id}, // Name+ID works, and is unchanged |
| 180 | {"nottest@" + id, ""}, // Name mismatch is rejected even with an ID |
| 181 | } { |
| 182 | input, err := Transport.ParseStoreReference(store, c.input) |
| 183 | require.NoError(t, err, c.input) |
| 184 | inputClone := *input |
| 185 | resolved, img, err := ResolveReference(input) |
| 186 | if c.expected == "" { |
| 187 | assert.Error(t, err, c.input) |
| 188 | } else { |
| 189 | require.NoError(t, err, c.input) |
| 190 | require.Equal(t, &inputClone, input) // input was not modified in-place |
| 191 | assert.Equal(t, id, img.ID, c.input) |
| 192 | assert.Equal(t, storeSpec+c.expected, resolved.StringWithinTransport(), c.input) |
| 193 | } |
| 194 | } |
| 195 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…