Skip to content

Commit

Permalink
test(jpa) destroy container after IT
Browse files Browse the repository at this point in the history
  • Loading branch information
mpumd committed Oct 14, 2024
1 parent 644c3f2 commit 09ae1fd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
25 changes: 12 additions & 13 deletions infra-spring/sb-out/src/main/resources/db.changelog-master.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ CREATE TABLE IF NOT EXISTS PERSON (
PRIMARY KEY (id)
);


--INSERT INTO PERSON (id, first_name, last_name, gender, birth_date, birth_place, nationality)
--VALUES
--('123e4567-e89b-12d3-a456-426614174000', 'Alice', 'Dupont', 'Female', '1990-05-15 10:30:00', 'Paris', 'French'),
--('223e4567-e89b-12d3-a456-426614174001', 'Bob', 'Martin', 'Male', '1985-11-20 14:45:00', 'Lyon', 'French'),
--('323e4567-e89b-12d3-a456-426614174002', 'Charlie', 'Durand', 'Male', '1992-03-12 09:15:00', 'Marseille', 'French'),
--('423e4567-e89b-12d3-a456-426614174003', 'Diane', 'Leroy', 'Female', '1988-07-25 18:00:00', 'Toulouse', 'French'),
--('523e4567-e89b-12d3-a456-426614174004', 'Eve', 'Moreau', 'Female', '1995-01-30 11:00:00', 'Nice', 'French'),
--('623e4567-e89b-12d3-a456-426614174005', 'Frank', 'Garnier', 'Male', '1991-04-17 07:50:00', 'Strasbourg', 'French'),
--('723e4567-e89b-12d3-a456-426614174006', 'Grace', 'Carre', 'Female', '1993-08-22 16:20:00', 'Bordeaux', 'French'),
--('823e4567-e89b-12d3-a456-426614174007', 'Hugo', 'Gauthier', 'Male', '1989-12-01 15:30:00', 'Nantes', 'French'),
--('923e4567-e89b-12d3-a456-426614174008', 'Isabelle', 'Simon', 'Female', '1994-09-10 13:05:00', 'Montpellier', 'French'),
--('a23e4567-e89b-12d3-a456-426614174009', 'Jean', 'Benoit', 'Male', '1987-06-14 12:00:00', 'Rennes', 'French');
INSERT INTO PERSON (id, first_name, last_name, gender, birth_date, birth_place, nationality)
VALUES
('123e4567-e89b-12d3-a456-426614174000', 'Alice', 'Dupont', 'Female', '1990-05-15 10:30:00', 'Paris', 'French'),
('223e4567-e89b-12d3-a456-426614174001', 'Bob', 'Martin', 'Male', '1985-11-20 14:45:00', 'Lyon', 'French'),
('323e4567-e89b-12d3-a456-426614174002', 'Charlie', 'Durand', 'Male', '1992-03-12 09:15:00', 'Marseille', 'French'),
('423e4567-e89b-12d3-a456-426614174003', 'Diane', 'Leroy', 'Female', '1988-07-25 18:00:00', 'Toulouse', 'French'),
('523e4567-e89b-12d3-a456-426614174004', 'Eve', 'Moreau', 'Female', '1995-01-30 11:00:00', 'Nice', 'French'),
('623e4567-e89b-12d3-a456-426614174005', 'Frank', 'Garnier', 'Male', '1991-04-17 07:50:00', 'Strasbourg', 'French'),
('723e4567-e89b-12d3-a456-426614174006', 'Grace', 'Carre', 'Female', '1993-08-22 16:20:00', 'Bordeaux', 'French'),
('823e4567-e89b-12d3-a456-426614174007', 'Hugo', 'Gauthier', 'Male', '1989-12-01 15:30:00', 'Nantes', 'French'),
('923e4567-e89b-12d3-a456-426614174008', 'Isabelle', 'Simon', 'Female', '1994-09-10 13:05:00', 'Montpellier', 'French'),
('a23e4567-e89b-12d3-a456-426614174009', 'Jean', 'Benoit', 'Male', '1987-06-14 12:00:00', 'Rennes', 'French');
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mpumd.poc.person.sb.jpa.mapper.DomainJPAMapper;
import lombok.SneakyThrows;
import org.jeasy.random.EasyRandom;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
Expand Down Expand Up @@ -40,7 +41,7 @@ class PersonJpaAdapterITest {
// TODO extract the postgres image name outside of here, anywhere who is possible de change easier it
@Container
@ServiceConnection
static final PostgreSQLContainer postgre = new PostgreSQLContainer("postgres:17-alpine");
static final PostgreSQLContainer postgresContainer = new PostgreSQLContainer("postgres:17-alpine");

@Autowired
PersonJpaAdapter adapter;
Expand All @@ -49,6 +50,12 @@ class PersonJpaAdapterITest {

EasyRandom easyRandom = new EasyRandom();

@AfterAll
static void afterAll() {
// default destroy container after IT, avoid the conflict with a local run
postgresContainer.close();
}

@Test
void pushInDBWithoutError() {
Person aggregatRoot = easyRandom.nextObject(Person.class);
Expand Down

0 comments on commit 09ae1fd

Please sign in to comment.