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.
This migration writes the current version number to the data directory. The remaining migrations depend on another open PR and will follow soon.
- Loading branch information
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
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
7 changes: 7 additions & 0 deletions
7
...ication/src/main/java/bisq/application/migration/migrations/MigrationFailedException.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,7 @@ | ||
package bisq.application.migration.migrations; | ||
|
||
public class MigrationFailedException extends RuntimeException { | ||
public MigrationFailedException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
application/src/main/java/bisq/application/migration/migrations/MigrationsForV2_1_2.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,26 @@ | ||
package bisq.application.migration.migrations; | ||
|
||
import bisq.common.application.ApplicationVersion; | ||
import bisq.common.platform.Version; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public class MigrationsForV2_1_2 implements Migration { | ||
|
||
@Override | ||
public void run(Path dataDir) { | ||
try { | ||
Path versionFilePath = dataDir.resolve("version"); | ||
Files.writeString(versionFilePath, ApplicationVersion.getVersion().toString()); | ||
} catch (IOException e) { | ||
throw new MigrationFailedException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public Version getVersion() { | ||
return new Version("2.1.2"); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ication/src/test/java/bisq/application/migration/migrations/MigrationsForV2_1_2Tests.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,28 @@ | ||
package bisq.application.migration.migrations; | ||
|
||
import bisq.common.application.ApplicationVersion; | ||
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; | ||
|
||
public class MigrationsForV2_1_2Tests { | ||
private final MigrationsForV2_1_2 migrationsForV212 = new MigrationsForV2_1_2(); | ||
|
||
@Test | ||
void migrationTest(@TempDir Path dataDir) throws IOException { | ||
Version version = migrationsForV212.getVersion(); | ||
Version expectedVersion = new Version("2.1.2"); | ||
assertThat(version).isEqualTo(expectedVersion); | ||
|
||
migrationsForV212.run(dataDir); | ||
String readVersion = Files.readString(dataDir.resolve("version")); | ||
assertThat(readVersion) | ||
.isEqualTo(ApplicationVersion.getVersion().toString()); | ||
} | ||
} |