Skip to content

Commit

Permalink
Trying to move part of the database construction into Demo1's base cl…
Browse files Browse the repository at this point in the history
…ass.
  • Loading branch information
michelleblom committed Nov 22, 2024
1 parent 05796da commit 4e664d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
import io.restassured.path.json.JsonPath;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.ext.ScriptUtils;
import org.testcontainers.jdbc.JdbcDatabaseDelegate;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import us.freeandfair.corla.persistence.Persistence;
Expand All @@ -52,12 +50,6 @@ public class Demo1 extends Workflow {
*/
private static final Logger LOGGER = LogManager.getLogger(Demo1.class);


/**
* Container for the mock-up database.
*/
private final static PostgreSQLContainer<?> postgres = createTestContainer();

/**
* Database init.
*/
Expand Down Expand Up @@ -146,8 +138,7 @@ public void runDemo1() throws InterruptedException {
assertEquals(dashboard.get(ASM_STATE), PARTIAL_AUDIT_INFO_SET.toString());

// 4. Generate assertions; sanity check
final var containerDelegate = new JdbcDatabaseDelegate(postgres, "");
generateAssertions("SQL/demo1-assertions.sql", containerDelegate,1);
generateAssertions("SQL/demo1-assertions.sql", 1);
dashboard = getDoSDashBoardRefreshResponse();

// There should be 4 IRV contests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.http.HttpStatus;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.ext.ScriptUtils;
import org.testcontainers.jdbc.JdbcDatabaseDelegate;
import org.testng.annotations.BeforeClass;
Expand Down Expand Up @@ -82,6 +83,11 @@ public class Workflow extends TestClassWithDatabase {
*/
private static final Logger LOGGER = LogManager.getLogger(Workflow.class);

/**
* Container for the mock-up database.
*/
protected final static PostgreSQLContainer<?> postgres = createTestContainer();

/**
* Path for storing temporary config files
*/
Expand Down Expand Up @@ -382,10 +388,10 @@ protected boolean uploadSuccessfulWithin(int timeAllowedSeconds, final Set<Integ
* See <a href="https://github.com/DemocracyDevelopers/colorado-rla/issues/218">...</a>
* Set it up so that we run raire-service inside the Docker container and tell main where to find it.
*/
protected void generateAssertions(final String sqlPath, final JdbcDatabaseDelegate delegate,
final double timeLimitSeconds)
protected void generateAssertions(final String sqlPath, final double timeLimitSeconds)
{
ScriptUtils.runInitScript(delegate, sqlPath);
final var containerDelegate = new JdbcDatabaseDelegate(postgres, "");
ScriptUtils.runInitScript(containerDelegate, sqlPath);

// Version that connects to raire-service below:
// Login as state admin.
Expand Down

0 comments on commit 4e664d9

Please sign in to comment.