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
58 lines (48 loc) · 2.19 KB
/
Copy pathDockerfileStatementAddTest.java
File metadata and controls
58 lines (48 loc) · 2.19 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
@RunWith(Enclosed.class)
public class DockerfileStatementAddTest {
@RunWith(Parameterized.class)
public static final class ParamTests {
@Parameterized.Parameters(name = "{0} {1} {2}")
public static Object[][] data() {
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"}};
}
@Parameterized.Parameter
public String command;
@Parameterized.Parameter(1)
public Matcher matchesExpectation;
@Parameterized.Parameter(2)
public String expectedDest;
@Test
public void testAddOrCopyPattern() {
Optional<DockerfileStatement.Add> optionalAdd = DockerfileStatement.Add.create(command);
assertThat(optionalAdd.isPresent(), is(true));
assertThat(optionalAdd.get().sources, matchesExpectation);
assertThat(optionalAdd.get().destination, is(expectedDest));
}
}
public static final class Tests {
@Test(expected = DockerClientException.class)
public void shouldThrowExceptionIfDestNotSpecified() {
DockerfileStatement.Add.create("ADD src");
}
}
}