Skip to content

Commit

Permalink
Added Docker portion from integration testing
Browse files Browse the repository at this point in the history
Note: If it isn't working, make sure to log out of docker. See: testcontainers/testcontainers-java#5121
  • Loading branch information
erik-lance committed Mar 11, 2023
1 parent 1e4af50 commit 40776c2
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.*;

import javax.annotation.PostConstruct;
import java.time.*;
import java.util.*;
import java.util.concurrent.*;
Expand All @@ -38,6 +39,18 @@ class EnlistControllerIT {
@Autowired
private StudentRepository studentRepository;

private final static String TEST = "test";

@Container
private final PostgreSQLContainer container = new PostgreSQLContainer("postgres:14")
.withDatabaseName(TEST).withUsername(TEST).withPassword(TEST);

@DynamicPropertySource
private static void properties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", () -> "jdbc:tc:postgresql:14:///" + TEST);
registry.add("spring.datasource.username", () -> TEST);
registry.add("spring.datasource.password", () -> TEST);
}

@Test
void enlist_student_in_section() throws Exception {
Expand Down

0 comments on commit 40776c2

Please sign in to comment.