FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve assertions by Sineaggi · Pull Request #2189 · docker-java/docker-java · GitHub

Repository navigation

Improve assertions - #2189

Merged
eddumelendez merged 1 commit into
docker-java:mainfrom
Sineaggi:it-cleanup
Oct 27, 2023
Merged

eddumelendez merged 1 commit into
docker-java:mainfrom
Sineaggi:it-cleanup

Conversation

Sineaggi commented Aug 21, 2023 •
edited
Loading

Copy link
Copy Markdown
Contributor

I've noticed a single test failing now and then on my MR #2041

Expected: is <1>
     but: was <0>

Sineaggi requested a review from a team as a code owner August 21, 2023 19:13
eddumelendez changed the title Add wait for flaky test Improve assertions Oct 26, 2023

Copy link
Copy Markdown
Member

@Sineaggi Thanks for your contribution! I already merged #2188. Can you please update your PR? Let's keep this one as an improvement for assertions

eddumelendez added this to the next milestone Oct 26, 2023
diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java
index c03df2a..3066767 100644
--- a/docker-java/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java
+++ b/docker-java/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java
@@ -26,11 +26,12 @@ import static java.util.Collections.singletonList;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.emptyString;
-import static org.hamcrest.Matchers.isOneOf;
 import static org.hamcrest.Matchers.not;
 import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.oneOf;
 import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.assertEquals;
 import static org.testinfected.hamcrest.jpa.PersistenceMatchers.hasField;
@@ -161,8 +162,8 @@ public class ListContainersCmdIT extends CmdIT {
                 .exec();

         assertThat(filteredContainers.size(), is(2));
-        assertThat(filteredContainers.get(0).getId(), isOneOf(id1, id2));
-        assertThat(filteredContainers.get(1).getId(), isOneOf(id1, id2));
+        assertThat(filteredContainers.get(0).getId(), is(oneOf(id1, id2)));
+        assertThat(filteredContainers.get(1).getId(), is(oneOf(id1, id2)));
     }

     @test
@@ -184,8 +185,8 @@ public class ListContainersCmdIT extends CmdIT {
                 .exec();

         assertThat(filteredContainers.size(), is(2));
-        assertThat(filteredContainers.get(0).getId(), isOneOf(id1, id2));
-        assertThat(filteredContainers.get(1).getId(), isOneOf(id1, id2));
+        assertThat(filteredContainers.get(0).getId(), is(oneOf(id1, id2)));
+        assertThat(filteredContainers.get(1).getId(), is(oneOf(id1, id2)));
     }

     @test
@@ -219,7 +220,7 @@ public class ListContainersCmdIT extends CmdIT {
                 .withStatusFilter(singletonList("running"))
                 .exec();

-        assertThat(filteredContainers.size(), is(1));
+        assertThat(filteredContainers, hasSize(1));
         assertThat(filteredContainers.get(0).getId(), is(containerId));
     }

@@ -239,7 +240,7 @@ public class ListContainersCmdIT extends CmdIT {
                 .withStatusFilter(singletonList("paused"))
                 .exec();

-        assertThat(filteredContainers.size(), is(1));
+        assertThat(filteredContainers, hasSize(1));
         assertThat(filteredContainers.get(0).getId(), is(containerId));
     }

@@ -260,7 +261,7 @@ public class ListContainersCmdIT extends CmdIT {
                 .withStatusFilter(singletonList("exited"))
                 .exec();

-        assertThat(filteredContainers.size(), is(1));
+        assertThat(filteredContainers, hasSize(1));
         assertThat(filteredContainers.get(0).getId(), is(containerId));
     }

@@ -289,7 +290,7 @@ public class ListContainersCmdIT extends CmdIT {
                 .withVolumeFilter(singletonList("TestFilterVolume"))
                 .exec();

-        assertThat(filteredContainers.size(), is(1));
+        assertThat(filteredContainers, hasSize(1));
         assertThat(filteredContainers.get(0).getId(), is(id));
     }

Sineaggi commented Oct 27, 2023 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

@eddumelendez I've rebased the pr.

eddumelendez merged commit 278a3ac into docker-java:main Oct 27, 2023

Copy link
Copy Markdown
Member

Thanks for your contribution, @Sineaggi !

Sineaggi deleted the it-cleanup branch October 27, 2023 19:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL