forked from bisq-network/bisq2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test MigrationService data directory version detection
- Test with data directory before MigrationService was introduced - Test with invalid data directory version - Test with valid data directory version
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
application/src/test/java/bisq/application/migration/MigrationServiceTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package bisq.application.migration; | ||
|
||
import bisq.common.platform.InvalidVersionException; | ||
import bisq.common.platform.Version; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class MigrationServiceTests { | ||
@Test | ||
void getDataDirVersionBeforeMigrationServiceIntroduced(@TempDir Path dataDir) { | ||
MigrationService migrationService = new MigrationService(dataDir); | ||
Version dataDirVersion = migrationService.getDataDirVersion(); | ||
assertThat(dataDirVersion) | ||
.isEqualTo(MigrationService.VERSION_BEFORE_MIGRATION_SERVICE_INTRODUCED); | ||
} | ||
|
||
@Test | ||
void getDataDirInvalidVersion(@TempDir Path dataDir) throws IOException { | ||
Path versionFilePath = dataDir.resolve("version"); | ||
Files.writeString(versionFilePath, "2.1-alpha"); | ||
|
||
MigrationService migrationService = new MigrationService(dataDir); | ||
assertThrows(InvalidVersionException.class, migrationService::getDataDirVersion); | ||
} | ||
|
||
@Test | ||
void getDataDirVersion(@TempDir Path dataDir) throws IOException { | ||
Path versionFilePath = dataDir.resolve("version"); | ||
Files.writeString(versionFilePath, "2.1.34"); | ||
|
||
MigrationService migrationService = new MigrationService(dataDir); | ||
Version dataDirVersion = migrationService.getDataDirVersion(); | ||
assertThat(dataDirVersion) | ||
.isEqualTo(new Version("2.1.34")); | ||
} | ||
} |