Skip to content

Commit

Permalink
removing temp dir after test completion
Browse files Browse the repository at this point in the history
  • Loading branch information
xshyamx committed Jun 28, 2022
1 parent 53edc27 commit 74c7fde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/test/java/org/apache/ibatis/migration/MigratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ void shouldInitTempDirectory() throws Exception {
assertEquals(3, scriptPath.list().length);
Migrator.main(TestUtil.args("--path=" + basePath.getAbsolutePath(), "new", "test new migration"));
assertEquals(4, scriptPath.list().length);
assertTrue(TestUtil.deleteDirectory(basePath), "delete temp dir");
}

@Test
Expand All @@ -344,6 +345,7 @@ void shouldRespectIdPattern() throws Exception {
File newMigration = new File(
basePath.getCanonicalPath() + File.separator + "scripts" + File.separator + "003_new_migration.sql");
assertTrue(newMigration.exists());
assertTrue(TestUtil.deleteDirectory(basePath), "delete temp dir");
}

@Test
Expand Down Expand Up @@ -371,6 +373,7 @@ void useCustomTemplate() throws Exception {
}
}
templatePath.delete();
assertTrue(TestUtil.deleteDirectory(basePath), "delete temp dir");
}

@Test
Expand All @@ -387,6 +390,7 @@ void useCustomTemplateWithNoValue() throws Exception {
Migrator.main(TestUtil.args("--path=" + basePath.getAbsolutePath(), "new", "test new migration", "--template="));
assertEquals(4, scriptPath.list().length);
templatePath.delete();
assertTrue(TestUtil.deleteDirectory(basePath), "delete temp dir");
}

@Test
Expand All @@ -405,6 +409,7 @@ void useCustomTemplateWithBadPath() throws Exception {
assertEquals(4, scriptPath.list().length);
assertTrue(output
.contains("Your migrations configuration did not find your custom template. Using the default template."));
assertTrue(TestUtil.deleteDirectory(basePath), "delete temp dir");
}

@Test
Expand All @@ -416,6 +421,7 @@ void shouldSuppressOutputIfQuietOptionEnabled() throws Throwable {
});
assertFalse(output.contains("Initializing:"));
assertNotNull(basePath.list());
assertTrue(TestUtil.deleteDirectory(basePath), "delete temp dir");
}

@Test
Expand All @@ -427,6 +433,7 @@ void shouldColorizeSuccessOutputIfColorOptionEnabled() throws Throwable {
});
assertTrue(output.contains(ConsoleColors.GREEN + "SUCCESS"));
assertNotNull(basePath.list());
assertTrue(TestUtil.deleteDirectory(basePath), "delete temp dir");
}

@Test
Expand All @@ -440,6 +447,7 @@ void shouldColorizeFailureOutputIfColorOptionEnabled() throws Throwable {
assertEquals(1, exitCode);
});
assertTrue(output.contains(ConsoleColors.RED + "FAILURE"));
assertTrue(TestUtil.deleteDirectory(basePath), "delete temp dir");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 the original author or authors.
* Copyright 2010-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,6 +51,7 @@ void shouldRunNewHooks() throws Throwable {
assertTrue(output.contains("Description is valid."));
assertTrue(output.contains("Renamed 03_create_table1_JIRA-123.sql to 03_create_table1_JIRA123.sql"));
assertTrue(new File(scriptPath, "03_create_table1_JIRA123.sql").exists());
assertTrue(TestUtil.deleteDirectory(basePath), "delete test dir");
}

@Test
Expand All @@ -65,6 +66,7 @@ void shouldNotCreateFileWhenBeforeHookThrowsException() throws Throwable {
});
assertTrue(output.contains("FAILURE"));
assertEquals(3, scriptPath.list().length);
assertTrue(TestUtil.deleteDirectory(basePath), "delete test dir");
}

protected File initBaseDir() throws IOException {
Expand Down

0 comments on commit 74c7fde

Please sign in to comment.