-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix AssetMigrationSource regex pattern
- Loading branch information
Showing
6 changed files
with
84 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
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 @@ | ||
CREATE IF NOT EXISTS TABLE key_value(key VARCHAR, val VARCHAR); |
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 @@ | ||
CREATE IF NOT EXISTS TABLE clients(id INTEGER, full_name VARCHAR, age INTEGER, dob INTEGER); |
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 @@ | ||
CREATE IF NOT EXISTS TABLE events(event_id INTEGER, json VARCHAR, server_version INTEGER); |
22 changes: 22 additions & 0 deletions
22
opensrp-app/src/test/java/org/smartregister/repository/dao/AppFolderMigrationSourceTest.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,22 @@ | ||
package org.smartregister.repository.dao; | ||
|
||
import org.junit.Test; | ||
import org.smartregister.BaseRobolectricUnitTest; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Ephraim Kigamba - [email protected] on 03-02-2021. | ||
*/ | ||
public class AppFolderMigrationSourceTest extends BaseRobolectricUnitTest { | ||
|
||
private | ||
|
||
@Test | ||
public void getMigrations() { | ||
} | ||
|
||
@Test | ||
public void testGetMigrations() { | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
opensrp-app/src/test/java/org/smartregister/repository/dao/AssetMigrationSourceTest.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,57 @@ | ||
package org.smartregister.repository.dao; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.robolectric.RuntimeEnvironment; | ||
import org.smartregister.BaseRobolectricUnitTest; | ||
import org.smartregister.repository.contract.MigrationSource; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Ephraim Kigamba - [email protected] on 02-02-2021. | ||
*/ | ||
public class AssetMigrationSourceTest extends BaseRobolectricUnitTest { | ||
|
||
private AssetMigrationSource assetMigrationSource; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
assetMigrationSource = new AssetMigrationSource(RuntimeEnvironment.application); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
} | ||
|
||
@Test | ||
public void getMigrationsShouldReturnAllMigrationsInAssetsFolder() { | ||
HashMap<Integer, ArrayList<MigrationSource.Migration>> migrations = | ||
assetMigrationSource.getMigrations(); | ||
|
||
assertEquals(3, migrations.size()); | ||
assertEquals(MigrationSource.Migration.MigrationType.UP, migrations.get(1).get(0).getMigrationType()); | ||
assertEquals(MigrationSource.Migration.MigrationType.UP, migrations.get(2).get(0).getMigrationType()); | ||
assertEquals("CREATE IF NOT EXISTS TABLE clients(id INTEGER, full_name VARCHAR, age INTEGER, dob INTEGER);" | ||
, migrations.get(2).get(0).getUpMigrationQueries()[0]); | ||
assertEquals(MigrationSource.Migration.MigrationType.UP, migrations.get(3).get(0).getMigrationType()); | ||
} | ||
|
||
@Test | ||
public void getMigrationsShouldReturnMigrationsFromV2() { | ||
|
||
HashMap<Integer, ArrayList<MigrationSource.Migration>> migrations = | ||
assetMigrationSource.getMigrations(2); | ||
|
||
assertEquals(2, migrations.size()); | ||
assertEquals(MigrationSource.Migration.MigrationType.UP, migrations.get(2).get(0).getMigrationType()); | ||
assertEquals("CREATE IF NOT EXISTS TABLE clients(id INTEGER, full_name VARCHAR, age INTEGER, dob INTEGER);" | ||
, migrations.get(2).get(0).getUpMigrationQueries()[0]); | ||
assertEquals(MigrationSource.Migration.MigrationType.UP, migrations.get(3).get(0).getMigrationType()); | ||
|
||
} | ||
} |