Skip to content

Commit

Permalink
find: adding unit test to confirm delete with exclude (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg authored Aug 3, 2023
1 parent 512d660 commit 1456fcf
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/java/me/itzg/helpers/find/FindCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,29 @@ void excludesByFiles() throws Exception {
);
}

@Test
void deleteWithExcludesByFilesInSubdir() throws Exception {
final Path a = Files.createFile(tempDir.resolve("a.txt"));
final Path subdir = Files.createDirectories(tempDir.resolve("subdir"));
final Path datFile = Files.createFile(subdir.resolve("b.dat"));
final Path c = Files.createFile(tempDir.resolve("c.cfg"));

final int exitCode = new CommandLine(new FindCommand())
.execute(
"--delete",
"--type", "f",
"--name=*",
"--exclude-name=*.dat",
tempDir.toString()
);

assertThat(exitCode).isEqualTo(ExitCode.OK);

assertThat(datFile).exists();
assertThat(a).doesNotExist();
assertThat(c).doesNotExist();
}

@Test
void excludesByDirectory() throws Exception {
Files.createFile(
Expand Down

0 comments on commit 1456fcf

Please sign in to comment.