Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure the migrations are ordered correctly
- Loading branch information
1 parent
2dd6e1e
commit 7ce4b16
Showing
2 changed files
with
43 additions
and
1 deletion.
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
37 changes: 36 additions & 1 deletion
37
src/test/java/dk/nsi/sdm4/core/persistence/migration/MigrationComparableTest.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 |
---|---|---|
@@ -1,10 +1,45 @@ | ||
package dk.nsi.sdm4.core.persistence.migration; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class MigrationComparableTest { | ||
private Migration migration2; | ||
private Migration migration1; | ||
private Migration migration3; | ||
private Migration migrationTime1; | ||
private Migration migrationTime2; | ||
|
||
@Before | ||
public void setup() { | ||
migration1 = new Migration("20120728_0101", null, null); | ||
migration2 = new Migration("20120828_0101", null, null); | ||
migration3 = new Migration("20120901_0101", null, null); | ||
|
||
migrationTime1 = new Migration("20120901_0101", null, null); | ||
migrationTime2 = new Migration("20120901_0102", null, null); | ||
} | ||
|
||
|
||
@Test | ||
public void comparesDifferentMonthsCorrectly() { | ||
assertTrue(migration1.compareTo(migration2) < 0); | ||
} | ||
|
||
@Test | ||
public void comparesTheVersionsAsDates() { | ||
public void doesNotJustUseTheDayOfMonth() { | ||
assertTrue(migration2.compareTo(migration3) < 0); | ||
} | ||
|
||
@Test | ||
public void canCrossSeveralMonths() { | ||
assertTrue(migration3.compareTo(migration1) > 0); | ||
} | ||
|
||
@Test | ||
public void understandsTimestampPartOfVersion() { | ||
assertTrue(migrationTime1.compareTo(migrationTime2) < 0); | ||
} | ||
} |