forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfileStatementAddTest.java
More file actions
44 lines (37 loc) · 1.93 KB
/
Copy pathDockerfileStatementAddTest.java
File metadata and controls
44 lines (37 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.github.dockerjava.core.dockerfile;
import com.github.dockerjava.api.exception.DockerClientException;
import com.google.common.base.Optional;
import org.hamcrest.Matcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
public class DockerfileStatementAddTest {
private static final Logger LOG = LoggerFactory.getLogger(DockerfileStatementAddTest.class);
@DataProvider(name = "valid scenarios")
public Object[][] validScenarios() {
return new Object[][] { {"ADD src dest", contains("src"), "dest"},
{"ADD \"src file\" \"dest\"", contains("src file"), "dest"},
{"ADD src\"file dest", contains("src\"file"), "dest"},
{"ADD src1 src2 dest", containsInAnyOrder("src1", "src2"), "dest"},
{"COPY src dest", contains("src"), "dest"},
{"COPY \"src file\" \"dest\"", contains("src file"), "dest"},
{"COPY src\"file dest", contains("src\"file"), "dest"},
{"COPY src1 src2 dest", containsInAnyOrder("src1", "src2"), "dest"}};
}
@Test(dataProvider = "valid scenarios")
public void testAddOrCopyPattern(String command, Matcher matchesExpectation, String expectedDest) {
Optional<DockerfileStatement.Add> optionalAdd = DockerfileStatement.Add.create(command);
assertThat(optionalAdd.isPresent(), is(true));
assertThat(optionalAdd.get().sources, matchesExpectation);
assertThat(optionalAdd.get().destination, is(expectedDest));
}
@Test(expectedExceptions = {DockerClientException.class})
public void shouldThrowExceptionIfDestNotSpecified() {
DockerfileStatement.Add.create("ADD src");
}
}