|
19 | 19 | import static org.assertj.core.api.BDDAssertions.then; |
20 | 20 | import static org.junit.jupiter.params.provider.Arguments.of; |
21 | 21 |
|
| 22 | +import io.github.ascopes.jct.tests.helpers.Fixtures; |
22 | 23 | import io.github.ascopes.jct.tests.helpers.UtilityClassTestTemplate; |
23 | 24 | import io.github.ascopes.jct.utils.StringUtils; |
24 | 25 | import java.lang.reflect.Type; |
@@ -426,33 +427,36 @@ void closestResultsUseTheGivenUserFriendlyRepresentation() { |
426 | 427 | @Test |
427 | 428 | void closestResultsAreComputedUsingTheGivenComparisonKey() { |
428 | 429 | // Given |
429 | | - var lookFor = "foo/bar/baz/bork"; |
430 | | - var existingObjects = List.of( |
431 | | - Path.of("foo", "baz"), |
432 | | - Path.of("foo", "bar"), |
433 | | - Path.of("foo", "bar", "baz"), |
434 | | - Path.of("foo", "bar", "baz", "qux") |
435 | | - ); |
436 | | - |
437 | | - // When |
438 | | - var actualMessage = StringUtils.resultNotFoundWithFuzzySuggestions( |
439 | | - Arrays.toString(lookFor.split("/")), |
440 | | - lookFor, |
441 | | - existingObjects, |
442 | | - path -> Arrays.toString(path.toString().split("\\|/")), |
443 | | - Path::toString, |
444 | | - "path" |
445 | | - ); |
446 | | - |
447 | | - // Then |
448 | | - assertThat(actualMessage.lines()) |
449 | | - .containsExactly( |
450 | | - "No path matching foo/bar/baz/bork was found. Maybe you meant:", |
451 | | - " - foo/bar", |
452 | | - " - foo/bar/baz", |
453 | | - " - foo/bar/baz/qux", |
454 | | - " - foo/baz" |
455 | | - ); |
| 430 | + try (var fs = Fixtures.someTemporaryFileSystem()) { |
| 431 | + |
| 432 | + var lookFor = "foo/bar/baz/bork"; |
| 433 | + var existingObjects = List.of( |
| 434 | + fs.getRootPath().resolve("foo").resolve("baz"), |
| 435 | + fs.getRootPath().resolve("foo").resolve("bar"), |
| 436 | + fs.getRootPath().resolve("foo").resolve("bar").resolve("baz"), |
| 437 | + fs.getRootPath().resolve("foo").resolve("bar").resolve("baz").resolve("qux") |
| 438 | + ); |
| 439 | + |
| 440 | + // When |
| 441 | + var actualMessage = StringUtils.resultNotFoundWithFuzzySuggestions( |
| 442 | + Arrays.toString(lookFor.split("/")), |
| 443 | + lookFor, |
| 444 | + existingObjects, |
| 445 | + path -> Arrays.toString(path.toString().split("/")), |
| 446 | + Path::toString, |
| 447 | + "path" |
| 448 | + ); |
| 449 | + |
| 450 | + // Then |
| 451 | + assertThat(actualMessage.lines()) |
| 452 | + .containsExactly( |
| 453 | + "No path matching foo/bar/baz/bork was found. Maybe you meant:", |
| 454 | + " - /foo/bar", |
| 455 | + " - /foo/bar/baz", |
| 456 | + " - /foo/bar/baz/qux", |
| 457 | + " - /foo/baz" |
| 458 | + ); |
| 459 | + } |
456 | 460 | } |
457 | 461 | } |
458 | 462 | } |
0 commit comments