Additional assertions to patch regression tests

- Check that the patches have been properly applied
- Check that removal works
This commit is contained in:
Rsl1122 2019-01-01 12:25:31 +02:00
parent f333ae7cc9
commit f8391305dc
4 changed files with 24 additions and 0 deletions

View File

@ -1,7 +1,10 @@
package com.djrapitops.plan.system.database.databases.sql;
import com.djrapitops.plan.system.database.databases.sql.patches.Patch;
import utilities.TestConstants;
import static org.junit.Assert.assertTrue;
public abstract class PatchRegression452Test {
String insertServer = "INSERT INTO plan_servers (uuid) VALUES ('" + TestConstants.SERVER_UUID + "')";
@ -28,4 +31,10 @@ public abstract class PatchRegression452Test {
underTest.execute(insertWorld);
underTest.execute(insertWorldTimes);
}
protected void assertPatchesHaveBeenApplied(SQLDB underTest) {
for (Patch patch : underTest.patches()) {
assertTrue("Patch " + patch.getClass().getSimpleName() + " was not applied properly.", patch.hasBeenApplied());
}
}
}

View File

@ -100,8 +100,13 @@ public class PatchRegressionH2452Test extends PatchRegression452Test {
// Patching might fail due to exception.
patchTask.run();
assertPatchesHaveBeenApplied(underTest);
// Make sure that a fetch works.
ServerContainer server = underTest.fetch().getServerContainer(TestConstants.SERVER_UUID);
OptionalAssert.equals(1, server.getValue(ServerKeys.PLAYER_KILL_COUNT));
// Make sure no foreign key checks fail on removal
underTest.remove().everything();
}
}

View File

@ -124,8 +124,13 @@ public class PatchRegressionMySQL452Test extends PatchRegression452Test {
// Patching might fail due to exception.
patchTask.run();
assertPatchesHaveBeenApplied(underTest);
// Make sure that a fetch works.
ServerContainer server = underTest.fetch().getServerContainer(TestConstants.SERVER_UUID);
OptionalAssert.equals(1, server.getValue(ServerKeys.PLAYER_KILL_COUNT));
// Make sure no foreign key checks fail on removal
underTest.remove().everything();
}
}

View File

@ -93,8 +93,13 @@ public class PatchRegressionSQLite452Test extends PatchRegression452Test {
// Patching might fail due to exception.
patchTask.run();
assertPatchesHaveBeenApplied(underTest);
// Make sure that a fetch works.
ServerContainer server = underTest.fetch().getServerContainer(TestConstants.SERVER_UUID);
OptionalAssert.equals(1, server.getValue(ServerKeys.PLAYER_KILL_COUNT));
// Make sure no foreign key checks fail on removal
underTest.remove().everything();
}
}