File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
package kr.itn.itnhub;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
@Testcontainers
class SchemaMigrationTest {
@Container
@ServiceConnection
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16");
@DynamicPropertySource
static void secrets(DynamicPropertyRegistry registry) {
registry.add("app.admin.username", () -> "admin");
registry.add("app.admin.password", () -> "test-password");
registry.add("mattermost.base-url", () -> "http://localhost:1");
registry.add("mattermost.token", () -> "test-token");
registry.add("mattermost.team-id", () -> "test-team");
}
@Autowired
JdbcTemplate jdbc;
@Test
void organization_테이블이_생성된다() {
Integer count = jdbc.queryForObject(
"select count(*) from information_schema.tables "
+ "where table_schema = 'itnhub' and table_name = 'organization'",
Integer.class);
assertThat(count).isEqualTo(1);
}
@Test
void 연번과_기관명_조합에_유니크_제약이_있다() {
jdbc.update("insert into organization (org_no, org_name, channel_slug) "
+ "values ('008', '경찰청', '008')");
assertThat(jdbc.queryForObject(
"select count(*) from organization where org_no = '008'", Integer.class))
.isEqualTo(1);
}
}