Skip to content

Commit

Permalink
Integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gthea committed Nov 26, 2024
1 parent 7bdc0f5 commit 5baf6fb
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions src/androidTest/java/tests/storage/GeneralInfoStorageTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package tests.storage;

import static org.junit.Assert.assertEquals;

import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import helper.DatabaseHelper;
import io.split.android.client.storage.db.SplitRoomDatabase;
import io.split.android.client.storage.general.GeneralInfoStorage;
import io.split.android.client.storage.general.GeneralInfoStorageImpl;

public class GeneralInfoStorageTest {

private SplitRoomDatabase mDb;
private GeneralInfoStorage mGeneralInfoStorage;

@Before
public void setUp() {
mDb = DatabaseHelper.getTestDatabase(InstrumentationRegistry.getInstrumentation().getContext());
mGeneralInfoStorage = new GeneralInfoStorageImpl(mDb.generalInfoDao());
}

@After
public void tearDown() {
mDb.clearAllTables();
mDb.close();
}

@Test
public void setSplitsUpdateTimestamp() {
long initialValue = mGeneralInfoStorage.getSplitsUpdateTimestamp();
mGeneralInfoStorage.setSplitsUpdateTimestamp(100L);
long finalValue = mGeneralInfoStorage.getSplitsUpdateTimestamp();

assertEquals(0L, initialValue);
assertEquals(100L, finalValue);
}

@Test
public void setChangeNumber() {
long initialValue = mGeneralInfoStorage.getChangeNumber();
mGeneralInfoStorage.setChangeNumber(100L);
long finalValue = mGeneralInfoStorage.getChangeNumber();

assertEquals(-1L, initialValue);
assertEquals(100L, finalValue);
}

@Test
public void setSplitsFilterQueryString() {
String initialValue = mGeneralInfoStorage.getSplitsFilterQueryString();
mGeneralInfoStorage.setSplitsFilterQueryString("queryString");
String finalValue = mGeneralInfoStorage.getSplitsFilterQueryString();

assertEquals("", initialValue);
assertEquals("queryString", finalValue);
}

@Test
public void setDatabaseEncryptionMode() {
String initialValue = mGeneralInfoStorage.getDatabaseEncryptionMode();
mGeneralInfoStorage.setDatabaseEncryptionMode("MODE");
String finalValue = mGeneralInfoStorage.getDatabaseEncryptionMode();

assertEquals("", initialValue);
assertEquals("MODE", finalValue);
}

@Test
public void setFlagsSpec() {
String initialValue = mGeneralInfoStorage.getFlagsSpec();
mGeneralInfoStorage.setFlagsSpec("4.4");
String finalValue = mGeneralInfoStorage.getFlagsSpec();

assertEquals("", initialValue);
assertEquals("4.4", finalValue);
}

@Test
public void setRolloutCacheLastClearTimestamp() {
long initialValue = mGeneralInfoStorage.getRolloutCacheLastClearTimestamp();
mGeneralInfoStorage.setRolloutCacheLastClearTimestamp(100L);
long finalValue = mGeneralInfoStorage.getRolloutCacheLastClearTimestamp();

assertEquals(0L, initialValue);
assertEquals(100L, finalValue);
}
}

0 comments on commit 5baf6fb

Please sign in to comment.