Ignore file order in test assertion (#1755)

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>
This commit is contained in:
Andrew Ross 2021-12-20 12:58:05 -06:00 committed by GitHub
parent ca27c8fd4f
commit ca40ba9c64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -91,9 +91,10 @@ public class UpdateShasTaskTests extends GradleUnitTestCase {
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