Separate tag in the Docker API tag call
Closes gh-35358
This commit is contained in:
@@ -75,6 +75,7 @@ import static org.mockito.Mockito.times;
|
||||
* @author Phillip Webb
|
||||
* @author Scott Frederick
|
||||
* @author Rafael Ceccone
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DockerApiTests {
|
||||
@@ -419,7 +420,17 @@ class DockerApiTests {
|
||||
void tagTagsImage() throws Exception {
|
||||
ImageReference sourceReference = ImageReference.of("localhost:5000/ubuntu");
|
||||
ImageReference targetReference = ImageReference.of("localhost:5000/ubuntu:tagged");
|
||||
URI tagURI = new URI(IMAGES_URL + "/localhost:5000/ubuntu/tag?repo=localhost%3A5000%2Fubuntu%3Atagged");
|
||||
URI tagURI = new URI(IMAGES_URL + "/localhost:5000/ubuntu/tag?repo=localhost%3A5000%2Fubuntu&tag=tagged");
|
||||
given(http().post(tagURI)).willReturn(emptyResponse());
|
||||
this.api.tag(sourceReference, targetReference);
|
||||
then(http()).should().post(tagURI);
|
||||
}
|
||||
|
||||
@Test
|
||||
void tagRenamesImage() throws Exception {
|
||||
ImageReference sourceReference = ImageReference.of("localhost:5000/ubuntu");
|
||||
ImageReference targetReference = ImageReference.of("localhost:5000/ubuntu-2");
|
||||
URI tagURI = new URI(IMAGES_URL + "/localhost:5000/ubuntu/tag?repo=localhost%3A5000%2Fubuntu-2");
|
||||
given(http().post(tagURI)).willReturn(emptyResponse());
|
||||
this.api.tag(sourceReference, targetReference);
|
||||
then(http()).should().post(tagURI);
|
||||
|
||||
@@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Scott Frederick
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class ImageReferenceTests {
|
||||
|
||||
@@ -272,4 +273,29 @@ class ImageReferenceTests {
|
||||
assertThat(r1).isEqualTo(r1).isEqualTo(r2).isNotEqualTo(r3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void withDigest() {
|
||||
ImageReference reference = ImageReference.of("docker.io/library/ubuntu:bionic");
|
||||
ImageReference updated = reference
|
||||
.withDigest("sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThat(updated).hasToString(
|
||||
"docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
}
|
||||
|
||||
@Test
|
||||
void inTaglessFormWithDigest() {
|
||||
ImageReference reference = ImageReference
|
||||
.of("docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
ImageReference updated = reference.inTaglessForm();
|
||||
assertThat(updated).hasToString(
|
||||
"docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
}
|
||||
|
||||
@Test
|
||||
void inTaglessForm() {
|
||||
ImageReference reference = ImageReference.of("docker.io/library/ubuntu:bionic");
|
||||
ImageReference updated = reference.inTaglessForm();
|
||||
assertThat(updated).hasToString("docker.io/library/ubuntu");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user