File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
src/test/java/com/amihaiemil/docker Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 2828import org .hamcrest .MatcherAssert ;
2929import org .hamcrest .Matchers ;
3030import org .junit .Test ;
31+
3132import java .io .File ;
33+ import java .util .Arrays ;
34+ import java .util .HashMap ;
35+ import java .util .Map ;
3236
3337/**
3438 * Integration tests for {@link RtImages}.
@@ -57,4 +61,34 @@ public void iteratesImages() throws Exception {
5761 );
5862 }
5963 }
64+
65+
66+ /**
67+ * {@link RtImages} can filter Images and return filtered Images.
68+ * @throws Exception If an error occurs.
69+ * @todo #187:30min To have multiple controlled images for filtering and
70+ * not the ubuntu image dependency for this test will be nice to have
71+ * the build Images implemented as described here:
72+ * https://docs.docker.com/engine/api/v1.37/#operation/ImageBuild.
73+ */
74+ @ Test
75+ public void filterImage () throws Exception {
76+ final Map <String , Iterable <String >> filters = new HashMap <>();
77+ filters .put (
78+ "reference" ,
79+ Arrays .asList (
80+ "ubuntu"
81+ )
82+ );
83+ final Images images = new LocalDocker (
84+ new File ("/var/run/docker.sock" )
85+ ).images ();
86+ Images filtered = images .filter (filters );
87+ for (final Image img : filtered ) {
88+ MatcherAssert .assertThat (
89+ img .getJsonArray ("RepoTags" ).getString (0 ),
90+ Matchers .is ("ubuntu:latest" )
91+ );
92+ }
93+ }
6094}
You can’t perform that action at this time.
0 commit comments