From ba7b9f3ad87acde7f5ef7ce8f2a0f65d16c995af Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sat, 4 Jun 2022 14:17:01 +0100 Subject: [PATCH] Added feature to allow repository to be kept intact after running certain tests --- src/test/java/org/qortal/test/common/Common.java | 11 +++++++++++ .../java/org/qortal/test/naming/IntegrityTests.java | 1 + 2 files changed, 12 insertions(+) diff --git a/src/test/java/org/qortal/test/common/Common.java b/src/test/java/org/qortal/test/common/Common.java index c45fcfd7..cb782343 100644 --- a/src/test/java/org/qortal/test/common/Common.java +++ b/src/test/java/org/qortal/test/common/Common.java @@ -61,6 +61,7 @@ public class Common { public static final String testSettingsFilename = "test-settings-v2.json"; + public static boolean shouldRetainRepositoryAfterTest = false; static { // Load/check settings, which potentially sets up blockchain config, etc. @@ -126,6 +127,7 @@ public class Common { public static void useSettings(String settingsFilename) throws DataException { Common.useSettingsAndDb(settingsFilename, true); + setShouldRetainRepositoryAfterTest(false); } public static void useDefaultSettings() throws DataException { @@ -207,7 +209,16 @@ public class Common { RepositoryManager.setRepositoryFactory(repositoryFactory); } + public static void setShouldRetainRepositoryAfterTest(boolean shouldRetain) { + shouldRetainRepositoryAfterTest = shouldRetain; + } + public static void deleteTestRepository() throws DataException { + if (shouldRetainRepositoryAfterTest) { + // Don't delete if we've requested to keep the db intact + return; + } + // Delete repository directory if exists Path repositoryPath = Paths.get(Settings.getInstance().getRepositoryPath()); try { diff --git a/src/test/java/org/qortal/test/naming/IntegrityTests.java b/src/test/java/org/qortal/test/naming/IntegrityTests.java index d08c8558..d52d4983 100644 --- a/src/test/java/org/qortal/test/naming/IntegrityTests.java +++ b/src/test/java/org/qortal/test/naming/IntegrityTests.java @@ -509,6 +509,7 @@ public class IntegrityTests extends Common { @Ignore("Checks 'live' repository") @Test public void testRepository() throws DataException { + Common.setShouldRetainRepositoryAfterTest(true); Settings.fileInstance("settings.json"); // use 'live' settings String repositoryUrlTemplate = "jdbc:hsqldb:file:%s" + File.separator + "blockchain;create=false;hsqldb.full_log_replay=true";