generated from pricelees/issue-pr-template
[#16] Reservation 도메인 코드 코틀린 마이그레이션 #17
@ -8,10 +8,11 @@ import jakarta.persistence.EntityManager
|
|||||||
import org.hamcrest.Matchers.equalTo
|
import org.hamcrest.Matchers.equalTo
|
||||||
import org.springframework.boot.test.context.SpringBootTest
|
import org.springframework.boot.test.context.SpringBootTest
|
||||||
import org.springframework.boot.test.web.server.LocalServerPort
|
import org.springframework.boot.test.web.server.LocalServerPort
|
||||||
import org.springframework.test.context.jdbc.Sql
|
|
||||||
import org.springframework.transaction.support.TransactionTemplate
|
import org.springframework.transaction.support.TransactionTemplate
|
||||||
import roomescape.theme.business.ThemeService
|
import roomescape.theme.business.ThemeService
|
||||||
import roomescape.theme.util.TestThemeCreateUtil
|
import roomescape.theme.util.TestThemeCreateUtil
|
||||||
|
import roomescape.util.CleanerMode
|
||||||
|
import roomescape.util.DatabaseCleanerExtension
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
@ -21,13 +22,14 @@ import kotlin.random.Random
|
|||||||
* 날짜 범위, 예약 수만 검증
|
* 날짜 범위, 예약 수만 검증
|
||||||
*/
|
*/
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@Sql(value = ["/truncate.sql"], executionPhase = Sql.ExecutionPhase.AFTER_TEST_CLASS)
|
|
||||||
class MostReservedThemeAPITest(
|
class MostReservedThemeAPITest(
|
||||||
@LocalServerPort val port: Int,
|
@LocalServerPort val port: Int,
|
||||||
val themeService: ThemeService,
|
val themeService: ThemeService,
|
||||||
val transactionTemplate: TransactionTemplate,
|
val transactionTemplate: TransactionTemplate,
|
||||||
val entityManager: EntityManager,
|
val entityManager: EntityManager,
|
||||||
) : FunSpec() {
|
) : FunSpec({
|
||||||
|
extension(DatabaseCleanerExtension(mode = CleanerMode.AFTER_SPEC))
|
||||||
|
}) {
|
||||||
init {
|
init {
|
||||||
beforeSpec {
|
beforeSpec {
|
||||||
transactionTemplate.executeWithoutResult {
|
transactionTemplate.executeWithoutResult {
|
||||||
|
|||||||
64
src/test/java/roomescape/util/DatabaseCleaner.kt
Normal file
64
src/test/java/roomescape/util/DatabaseCleaner.kt
Normal file
@ -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<String> 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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);
|
|
||||||
@ -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');
|
|
||||||
@ -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;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user