Skip to content

Commit

Permalink
feat(objectionary#2746): fix returnsFromCacheCorrectProgram
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanich96 committed Dec 28, 2023
1 parent 76b56a8 commit 11eef4b
Showing 1 changed file with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ void returnsFromCacheButTimesSaveAndExecuteDifferent(@TempDir final Path tmp)
final XML program = OptCachedTest.program(ZonedDateTime.now().minusMinutes(2));
OptCachedTest.save(tmp, program);
MatcherAssert.assertThat(
String.format(
"We expected that the not immediately saved program will be returned from the cache"
),
"We expected that the not immediately saved program will be returned from the cache",
new OptCached(
path -> {
throw new IllegalStateException("This code shouldn't be executed");
Expand All @@ -98,20 +96,16 @@ void returnsFromCacheButTimesSaveAndExecuteDifferent(@TempDir final Path tmp)
@Test
void returnsFromCacheCorrectProgram(@TempDir final Path tmp)
throws IOException {
XML program = OptCachedTest.program(ZonedDateTime.now(), "first program");
OptCachedTest.save(tmp, program);
program = OptCachedTest.program(ZonedDateTime.now(), "second program");
final XML prev = OptCachedTest.program(ZonedDateTime.now(), "first program");
OptCachedTest.save(tmp, prev);
final XML current = OptCachedTest.program(ZonedDateTime.now(), "second program");
MatcherAssert.assertThat(
String.format(
"We expected the program corresponding to the code will be returned from the cache"
),
"Expecting current program to be compiled, but prev program was returned from cache",
new OptCached(
path -> {
throw new IllegalStateException("This code shouldn't be executed");
},
path -> current,
tmp
).apply(program),
Matchers.equalTo(program)
).apply(current),
Matchers.equalTo(current)
);
}

Expand Down

0 comments on commit 11eef4b

Please sign in to comment.