From 9008e612e3136ad685463d9f63701e6151759155 Mon Sep 17 00:00:00 2001 From: pricelees Date: Mon, 21 Jul 2025 20:57:37 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=97=90?= =?UTF-8?q?=EC=84=9C=EC=9D=98=20=ED=85=8C=EC=9D=B4=EB=B8=94=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EB=B0=8F=20SQL=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../theme/web/MostReservedThemeAPITest.kt | 8 +- .../java/roomescape/util/DatabaseCleaner.kt | 64 ++++++ src/test/resources/reservationData.sql | 194 ------------------ src/test/resources/test_search_data.sql | 41 ---- src/test/resources/truncate.sql | 25 --- 5 files changed, 69 insertions(+), 263 deletions(-) create mode 100644 src/test/java/roomescape/util/DatabaseCleaner.kt delete mode 100644 src/test/resources/reservationData.sql delete mode 100644 src/test/resources/test_search_data.sql delete mode 100644 src/test/resources/truncate.sql diff --git a/src/test/java/roomescape/theme/web/MostReservedThemeAPITest.kt b/src/test/java/roomescape/theme/web/MostReservedThemeAPITest.kt index 8931f6a2..73b62fdf 100644 --- a/src/test/java/roomescape/theme/web/MostReservedThemeAPITest.kt +++ b/src/test/java/roomescape/theme/web/MostReservedThemeAPITest.kt @@ -8,10 +8,11 @@ import jakarta.persistence.EntityManager import org.hamcrest.Matchers.equalTo import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.web.server.LocalServerPort -import org.springframework.test.context.jdbc.Sql import org.springframework.transaction.support.TransactionTemplate import roomescape.theme.business.ThemeService import roomescape.theme.util.TestThemeCreateUtil +import roomescape.util.CleanerMode +import roomescape.util.DatabaseCleanerExtension import java.time.LocalDate import kotlin.random.Random @@ -21,13 +22,14 @@ import kotlin.random.Random * 날짜 범위, 예약 수만 검증 */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@Sql(value = ["/truncate.sql"], executionPhase = Sql.ExecutionPhase.AFTER_TEST_CLASS) class MostReservedThemeAPITest( @LocalServerPort val port: Int, val themeService: ThemeService, val transactionTemplate: TransactionTemplate, val entityManager: EntityManager, -) : FunSpec() { +) : FunSpec({ + extension(DatabaseCleanerExtension(mode = CleanerMode.AFTER_SPEC)) +}) { init { beforeSpec { transactionTemplate.executeWithoutResult { diff --git a/src/test/java/roomescape/util/DatabaseCleaner.kt b/src/test/java/roomescape/util/DatabaseCleaner.kt new file mode 100644 index 00000000..17e83bf6 --- /dev/null +++ b/src/test/java/roomescape/util/DatabaseCleaner.kt @@ -0,0 +1,64 @@ +package roomescape.util + +import io.kotest.core.listeners.AfterSpecListener +import io.kotest.core.listeners.AfterTestListener +import io.kotest.core.spec.Spec +import io.kotest.core.test.TestCase +import io.kotest.core.test.TestResult +import io.kotest.extensions.spring.testContextManager +import jakarta.persistence.EntityManager +import org.springframework.jdbc.core.JdbcTemplate +import org.springframework.stereotype.Component + +@Component +class DatabaseCleaner( + val entityManager: EntityManager, + val jdbcTemplate: JdbcTemplate, +) { + val tables: List by lazy { + jdbcTemplate.query("SHOW TABLES") { rs, _ -> + rs.getString(1).lowercase() + } + } + + fun clear() { + entityManager.clear() + + jdbcTemplate.execute("SET REFERENTIAL_INTEGRITY FALSE") + tables.forEach { + jdbcTemplate.execute("TRUNCATE TABLE $it RESTART IDENTITY") + } + jdbcTemplate.execute("SET REFERENTIAL_INTEGRITY TRUE") + } +} + +enum class CleanerMode { + AFTER_EACH_TEST, + AFTER_SPEC +} + +class DatabaseCleanerExtension( + private val mode: CleanerMode +) : AfterTestListener, AfterSpecListener { + override suspend fun afterTest(testCase: TestCase, result: TestResult) { + super.afterTest(testCase, result) + when (mode) { + CleanerMode.AFTER_EACH_TEST -> getCleaner().clear() + CleanerMode.AFTER_SPEC -> Unit + } + } + + override suspend fun afterSpec(spec: Spec) { + super.afterSpec(spec) + when (mode) { + CleanerMode.AFTER_EACH_TEST -> Unit + CleanerMode.AFTER_SPEC -> getCleaner().clear() + } + } + + private suspend fun getCleaner(): DatabaseCleaner { + return testContextManager().testContext + .applicationContext + .getBean(DatabaseCleaner::class.java) + } +} diff --git a/src/test/resources/reservationData.sql b/src/test/resources/reservationData.sql deleted file mode 100644 index b5a4c521..00000000 --- a/src/test/resources/reservationData.sql +++ /dev/null @@ -1,194 +0,0 @@ -INSERT INTO member (name, password, email, role) -VALUES ('이름', '12341234', 'test@test.com', 'MEMBER'); -INSERT INTO member (name, password, email, role) -VALUES ('관리자', '12341234', 'admin@admin.com', 'ADMIN'); - - --- 테마 목록 : 11개 -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마1', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마2', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마3', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마4', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마5', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마6', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마7', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마8', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마9', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마10', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); -INSERT INTO theme (name, description, thumbnail) -VALUES ('테마11', '재밌는 테마입니다', - 'https://www.google.co.kr/url?sa=i&url=http%3A%2F%2Fwww.code-k.co.kr%2Fsub%2Fcode_sub03.html%3FR_JIJEM%3DS1&psig=AOvVaw20fNjL28MSMMiR0Nb57Eh-&ust=1714695060162000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCOiO2oLX7YUDFQAAAAAdAAAAABAE'); - --- 예약 시간 목록 : 5개 -INSERT INTO reservation_time (start_at) -VALUES ('08:00'); -INSERT INTO reservation_time (start_at) -VALUES ('10:00'); -INSERT INTO reservation_time (start_at) -VALUES ('13:00'); -INSERT INTO reservation_time (start_at) -VALUES ('21:00'); -INSERT INTO reservation_time (start_at) -VALUES ('23:00'); - --- 5,4,2,5,2,3,1,1,1,1,1 --- 내림차순 정렬 ID : 4/1, 2, 6, 3/5, 7/8/9/10/11 - --- 테마 1 예약 목록 : 5개 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 1, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 2, 1, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 3, 1, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 4, 1, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 5, 1, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-1', 'paymentKey-1', 10000, 1, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-2', 'paymentKey-2', 20000, 2, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-3', 'paymentKey-3', 30000, 3, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-4', 'paymentKey-4', 40000, 4, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-5', 'paymentKey-5', 50000, 5, CURRENT_DATE); - --- 테마 2 예약 목록 : 4개 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 2, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 2, 2, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 3, 2, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 4, 2, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-6', 'paymentKey-6', 50000, 6, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-7', 'paymentKey-7', 50000, 7, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-8', 'paymentKey-8', 50000, 8, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-9', 'paymentKey-9', 50000, 9, CURRENT_DATE); - - --- 테마 3 예약 목록 : 2개 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 3, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 2, 3, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-10', 'paymentKey-10', 50000, 10, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-11', 'paymentKey-11', 50000, 11, CURRENT_DATE); - --- 테마 4 예약 목록 : 5개 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 4, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 2, 4, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 3, 4, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 4, 4, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 5, 4, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-12', 'paymentKey-12', 50000, 12, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-13', 'paymentKey-13', 50000, 13, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-14', 'paymentKey-14', 50000, 14, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-15', 'paymentKey-15', 50000, 15, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-16', 'paymentKey-16', 50000, 16, CURRENT_DATE); - --- 테마 5 예약 목록 : 2개 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 5, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 5, 5, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-17', 'paymentKey-17', 50000, 17, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-18', 'paymentKey-18', 50000, 18, CURRENT_DATE); - --- 테마 6 예약 목록 : 3개 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 6, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 2, 6, 1, 'CONFIRMED'); -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 3, 6, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-19', 'paymentKey-19', 50000, 19, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-20', 'paymentKey-20', 50000, 20, CURRENT_DATE); -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-21', 'paymentKey-21', 50000, 21, CURRENT_DATE); - --- 테마 7 예약 목록 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 7, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-22', 'paymentKey-22', 50000, 22, CURRENT_DATE); - --- 테마 8 예약 목록 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 8, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-23', 'paymentKey-23', 50000, 23, CURRENT_DATE); - - --- 테마 9 예약 목록 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 9, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-24', 'paymentKey-24', 50000, 24, CURRENT_DATE); - --- 테마 10 예약 목록 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 1, 10, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-25', 'paymentKey-25', 50000, 25, CURRENT_DATE); - --- 테마 11 예약 목록 -INSERT INTO reservation (date, time_id, theme_id, member_id, reservation_status) -VALUES (DATEADD('DAY', -3, CURRENT_DATE), 5, 11, 1, 'CONFIRMED'); - -insert into payment(order_id, payment_key, total_amount, reservation_id, approved_at) -values ('orderId-26', 'paymentKey-26', 50000, 26, CURRENT_DATE); diff --git a/src/test/resources/test_search_data.sql b/src/test/resources/test_search_data.sql deleted file mode 100644 index c288d560..00000000 --- a/src/test/resources/test_search_data.sql +++ /dev/null @@ -1,41 +0,0 @@ --- 관리자가 특정 조건에 해당되는 예약을 조회하는 테스트에서만 사용되는 데이터입니다. -insert into reservation_time(start_at) -values ('15:00'); - -insert into theme(name, description, thumbnail) -values ('테스트1', '테스트중', 'https://i.pinimg.com/236x/6e/bc/46/6ebc461a94a49f9ea3b8bbe2204145d4.jpg'); -insert into theme(name, description, thumbnail) -values ('테스트2', '테스트중', 'https://i.pinimg.com/236x/6e/bc/46/6ebc461a94a49f9ea3b8bbe2204145d4.jpg'); - -insert into member(name, email, password, role) -values ('어드민', 'a@a.a', 'a', 'ADMIN'); -insert into member(name, email, password, role) -values ('1호', '1@1.1', '1', 'MEMBER'); - --- 예약 --- 시간은 같은 시간으로, 날짜는 어제부터 7일 전까지 --- memberId = 1인 멤버는 3개의 예약, memberId = 2인 멤버는 4개의 예약이 있음 --- themeId = 1인 테마는 4개의 예약, themeId = 2인 테마는 3개의 예약이 있음 -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', -1, CURRENT_DATE()), 1, 1, 1, 'CONFIRMED'); -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', -2, CURRENT_DATE()), 1, 1, 1, 'CONFIRMED'); -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', -3, CURRENT_DATE()), 1, 1, 1, 'CONFIRMED'); -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', -4, CURRENT_DATE()), 1, 1, 2, 'CONFIRMED'); -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', -5, CURRENT_DATE()), 1, 2, 2, 'CONFIRMED'); -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', -6, CURRENT_DATE()), 1, 2, 2, 'CONFIRMED'); -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', -7, CURRENT_DATE()), 1, 2, 2, 'CONFIRMED'); - --- 예약 대기 --- 예약 대기는 조회되면 안됨. -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', 7, CURRENT_DATE()), 1, 1, 1, 'WAITING'); -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', 8, CURRENT_DATE()), 1, 1, 1, 'WAITING'); -insert into reservation(date, time_id, theme_id, member_id, reservation_status) -values (DATEADD('DAY', 9, CURRENT_DATE()), 1, 1, 2, 'WAITING'); diff --git a/src/test/resources/truncate.sql b/src/test/resources/truncate.sql deleted file mode 100644 index cd541e0e..00000000 --- a/src/test/resources/truncate.sql +++ /dev/null @@ -1,25 +0,0 @@ -DELETE -FROM payment; -DELETE -FROM canceled_payment; -DELETE -FROM reservation; -DELETE -FROM reservation_time; -DELETE -FROM theme; -DELETE -FROM member; - -ALTER TABLE payment - ALTER COLUMN id RESTART WITH 1; -ALTER TABLE canceled_payment - ALTER COLUMN id RESTART WITH 1; -ALTER TABLE reservation - ALTER COLUMN id RESTART WITH 1; -ALTER TABLE reservation_time - ALTER COLUMN id RESTART WITH 1; -ALTER TABLE theme - ALTER COLUMN id RESTART WITH 1; -ALTER TABLE member - ALTER COLUMN id RESTART WITH 1;