Skip to content

Commit

Permalink
Ignore file order in test assertion
Browse files Browse the repository at this point in the history
This unit test asserts that a SHA file for a groovy dependency gets
created. However, a SHA file for javaparser-core also gets created in
the same directory. For some reason, builds were failing on my machine
because `Files::list` was returning the javaparser-core file first. I
don't believe there are any ordering guarantees with that API, so I
relaxed the assertion to not depend on ordering.

Signed-off-by: Andrew Ross <andrross@amazon.com>
  • Loading branch information
andrross committed Dec 16, 2021
1 parent 82a4f45 commit 7e0fa7d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ public void whenDependencyExistsButShaNotThenShouldCreateNewShaFile() throws IOE
getLicensesDir(project).mkdir();
task.updateShas();

Path groovySha = Files.list(getLicensesDir(project).toPath()).findFirst().get();

assertTrue(groovySha.toFile().getName().startsWith("groovy-"));
assertTrue(
"Expected a sha file to exist with a name prefix of 'groovy-",
Files.list(getLicensesDir(project).toPath()).anyMatch(sha -> sha.toFile().getName().startsWith("groovy-"))
);
}

@Test
Expand Down

0 comments on commit 7e0fa7d

Please sign in to comment.