Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a4103ca

Browse files
committed
Recover fix to testPullImage from commit 2a6d92d, accidentally lost in 4ac45cd
1 parent e418e2e commit a4103ca

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/main/java/com/kpelykh/docker/client/DockerClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public ClientResponse pull(String repository, String tag, String registry) throw
187187
Preconditions.checkNotNull(repository, "Repository was not specified");
188188

189189
if (StringUtils.countMatches(repository, ":") == 1) {
190-
String repositoryTag[] = StringUtils.split(repository);
190+
String repositoryTag[] = StringUtils.split(repository, ':');
191191
repository = repositoryTag[0];
192192
tag = repositoryTag[1];
193193

src/test/java/com/kpelykh/docker/client/test/DockerClientTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,11 @@ public void removeContainer() throws DockerException {
474474
@Test
475475
public void testPullImage() throws DockerException, IOException {
476476

477-
String testImage = "kpelykh/vimbase";
477+
// This should be an image that is not used by other repositories already
478+
// pulled down, preferably small in size. If tag is not used pull will
479+
// download all images in that repository but tmpImgs will only
480+
// deleted 'latest' image but not images with other tags
481+
String testImage = "hackmann/empty";
478482

479483
LOG.info("Removing image: {}", testImage);
480484
dockerClient.removeImage(testImage);
@@ -486,6 +490,7 @@ public void testPullImage() throws DockerException, IOException {
486490

487491
LOG.info("Pulling image: {}", testImage);
488492

493+
tmpImgs.add(testImage);
489494
ClientResponse response = dockerClient.pull(testImage);
490495

491496
StringWriter logwriter = new StringWriter();
@@ -503,15 +508,12 @@ public void testPullImage() throws DockerException, IOException {
503508
}
504509

505510
String fullLog = logwriter.toString();
506-
assertThat(fullLog,
507-
containsString("Pulling repository kpelykh/vimbase"));
508-
509-
tmpImgs.add(testImage);
511+
assertThat(fullLog, containsString("Download complete"));
510512

511513
info = dockerClient.info();
512514
LOG.info("Client info after pull, {}", info.toString());
513515

514-
assertThat(imgCount + 1, equalTo(info.getImages()));
516+
assertThat(imgCount, lessThan(info.getImages()));
515517

516518
ImageInspectResponse imageInspectResponse = dockerClient
517519
.inspectImage(testImage);

0 commit comments

Comments
 (0)