Add database auto updating

This commit is contained in:
James Seibel
2023-10-02 19:54:43 -05:00
parent 94b2b63767
commit 1ec06fa94e
9 changed files with 177 additions and 56 deletions
@@ -50,6 +50,9 @@ public class TestDataRepo extends AbstractDhRepo<TestDto>
@Override
public String getTableName() { return "Test"; }
@Override
public String getPrimaryKeyName() { return "Id"; }
@Override
public TestDto convertResultSetToDto(ResultSet resultSet) throws SQLException
+19 -6
View File
@@ -19,12 +19,14 @@
package tests;
import com.seibel.distanthorizons.core.sql.DatabaseUpdater;
import org.junit.Assert;
import org.junit.Test;
import testItems.sql.TestDataRepo;
import testItems.sql.TestDto;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
@@ -57,6 +59,23 @@ public class DhRepoSqliteTest
Assert.assertTrue("dbFile not created", dbFile.exists());
//==========================//
// Auto update script tests //
//==========================//
ResultSet autoUpdateTablePresentResult = testDataRepo.query("SELECT name FROM sqlite_master WHERE type='table' AND name='"+DatabaseUpdater.SCHEMA_TABLE_NAME+"';");
if (!autoUpdateTablePresentResult.next() || autoUpdateTablePresentResult.getString(1) == null)
{
Assert.fail("Auto DB update table missing.");
}
//===========//
// DTO tests //
//===========//
// insert
TestDto insertDto = new TestDto(0, "a");
testDataRepo.save(insertDto);
@@ -97,12 +116,6 @@ public class DhRepoSqliteTest
{
testDataRepo.close();
}
dbFile = new File(dbFileName);
if (dbFile.exists())
{
Assert.assertTrue("unable to delete test DB File.", dbFile.delete());
}
}
}