Skip to content

Commit

Permalink
Add test with existing database objects
Browse files Browse the repository at this point in the history
  • Loading branch information
milderhc committed Oct 9, 2023
1 parent ff4bd11 commit ddd36f4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

public class JDBCMemoryStoreTest {

private static JDBCMemoryStore.Builder builder;
private static MemoryStore db;
private static int collectionNum = 0;
private static final String NULL_ADDITIONAL_METADATA = null;
Expand All @@ -40,11 +41,9 @@ public class JDBCMemoryStoreTest {

@BeforeAll
static void setUp() throws SQLException {
db =
new JDBCMemoryStore.Builder()
.withConnection(DriverManager.getConnection("jdbc:sqlite::memory:"))
.buildAsync()
.block();
builder = new JDBCMemoryStore.Builder()
.withConnection(DriverManager.getConnection("jdbc:sqlite::memory:"));
db = builder.buildAsync().block();
}

private Collection<MemoryRecord> createBatchRecords(int numRecords) {
Expand Down Expand Up @@ -86,6 +85,15 @@ void initializeDbConnectionSucceeds() {
assertNotNull(db);
}

@Test
void itDoesNotFailWithExistingTables() {
// Act
db = builder.buildAsync().block();

// Assert
assertNotNull(db);
}

@Test
void itCanCreateAndGetCollectionAsync() {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class MySQLMemoryStoreTest {
private static final String MYSQL_USER = "test";
private static final String MYSQL_PASSWORD = "test";

private static MySQLMemoryStore.Builder builder;
private static MemoryStore db;
private static int collectionNum = 0;
private static final String NULL_ADDITIONAL_METADATA = null;
Expand All @@ -37,13 +38,11 @@ public class MySQLMemoryStoreTest {

@BeforeAll
static void setUp() throws SQLException {
db =
new MySQLMemoryStore.Builder()
.withConnection(
DriverManager.getConnection(
CONTAINER.getJdbcUrl(), MYSQL_USER, MYSQL_PASSWORD))
.buildAsync()
.block();
builder = new MySQLMemoryStore.Builder()
.withConnection(
DriverManager.getConnection(
CONTAINER.getJdbcUrl(), MYSQL_USER, MYSQL_PASSWORD));
db = builder.buildAsync().block();
}

private Collection<MemoryRecord> createBatchRecords(int numRecords) {
Expand Down Expand Up @@ -85,6 +84,15 @@ void initializeDbConnectionSucceeds() {
assertNotNull(db);
}

@Test
void itDoesNotFailWithExistingTables() {
// Act
db = builder.buildAsync().block();

// Assert
assertNotNull(db);
}

@Test
void itCanCreateAndGetCollectionAsync() throws IOException {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class PostgreSQLMemoryStoreTest {
private static final String POSTGRES_USER = "test";
private static final String POSTGRES_PASSWORD = "test";

private static PostgreSQLMemoryStore.Builder builder;
private static MemoryStore db;
private static int collectionNum = 0;
private static final String NULL_ADDITIONAL_METADATA = null;
Expand All @@ -37,13 +38,11 @@ public class PostgreSQLMemoryStoreTest {

@BeforeAll
static void setUp() throws SQLException {
db =
new PostgreSQLMemoryStore.Builder()
builder = new PostgreSQLMemoryStore.Builder()
.withConnection(
DriverManager.getConnection(
CONTAINER.getJdbcUrl(), POSTGRES_USER, POSTGRES_PASSWORD))
.buildAsync()
.block();
CONTAINER.getJdbcUrl(), POSTGRES_USER, POSTGRES_PASSWORD));
db = builder.buildAsync().block();
}

private Collection<MemoryRecord> createBatchRecords(int numRecords) {
Expand Down Expand Up @@ -85,6 +84,15 @@ void initializeDbConnectionSucceeds() {
assertNotNull(db);
}

@Test
void itDoesNotFailWithExistingTables() {
// Act
db = builder.buildAsync().block();

// Assert
assertNotNull(db);
}

@Test
void itCanCreateAndGetCollectionAsync() throws IOException {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

public class SQLiteMemoryStoreTest {

private static SQLiteMemoryStore.Builder builder;
private static MemoryStore db;
private static int collectionNum = 0;
private static final String NULL_ADDITIONAL_METADATA = null;
Expand All @@ -38,7 +39,8 @@ public class SQLiteMemoryStoreTest {

@BeforeAll
static void setUp() throws SQLException {
db = new SQLiteMemoryStore.Builder().withFilename(":memory:").buildAsync().block();
builder = new SQLiteMemoryStore.Builder().withFilename(":memory:");
db = builder.buildAsync().block();
}

private Collection<MemoryRecord> createBatchRecords(int numRecords) {
Expand Down Expand Up @@ -80,6 +82,15 @@ void initializeDbConnectionSucceeds() {
assertNotNull(db);
}

@Test
void itDoesNotFailWithExistingTables() {
// Act
db = builder.buildAsync().block();

// Assert
assertNotNull(db);
}

@Test
void itCanCreateAndGetCollectionAsync() {
// Arrange
Expand Down

0 comments on commit ddd36f4

Please sign in to comment.