Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ jobs:
build-and-test:
runs-on: ubuntu-latest

services:
redis:
image: redis:7.0-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -24,7 +35,11 @@ jobs:
run: chmod +x ./gradlew

- name: Build Project
run: ./gradlew build
run: ./gradlew build -x test

- name: Run tests
run: ./gradlew clean test
env:
SPRING_REDIS_HOST: localhost
SPRING_REDIS_PORT: 6379

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("test")
@SpringBootTest
class Booking911ApplicationTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import nbc.ticketing.ticket911.domain.auth.vo.AuthUser;
import nbc.ticketing.ticket911.domain.booking.application.BookingService;
Expand All @@ -33,6 +34,7 @@
import nbc.ticketing.ticket911.domain.user.entity.User;
import nbc.ticketing.ticket911.domain.user.repository.UserRepository;

@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
class BookingControllerTestByMySQL {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package nbc.ticketing.ticket911.domain.lock;

import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
Expand All @@ -18,10 +17,13 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.bean.override.mockito.MockitoBean;

import nbc.ticketing.ticket911.common.aop.RedissonMultiLockAspect;
import nbc.ticketing.ticket911.domain.auth.vo.AuthUser;
import nbc.ticketing.ticket911.domain.booking.application.BookingService;
import nbc.ticketing.ticket911.domain.booking.dto.request.BookingRequestDto;
Expand All @@ -44,6 +46,9 @@

@SpringBootTest
@ActiveProfiles("test")
@Import(RedissonMultiLockAspect.class)
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.ANY)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
class LettuceLockManagerTest {
@Autowired
private BookingService bookingService;
Expand All @@ -54,7 +59,7 @@ class LettuceLockManagerTest {
@Autowired
private BookingDomainService bookingDomainService;

@MockitoBean
@Autowired
private UserDomainService userDomainService;
@Autowired
private ConcertSeatRepository concertSeatRepository;
Expand Down Expand Up @@ -84,9 +89,6 @@ void setupConcertSeat() {
.build()
);

when(userDomainService.findActiveUserById(savedUser.getId()))
.thenReturn(savedUser);

Stage savedStage = stageRepository.save(
Stage.builder()
.totalSeat(1L)
Expand Down Expand Up @@ -155,6 +157,7 @@ void setupConcertSeat() {

assertThat(resultStats.getOrDefault("성공", 0L)).isEqualTo(1);
}

@Test
void 동시_예매_테스트_좌석은_하나만_성공해야_한다_AOP기반() throws InterruptedException {
int threadCount = 100;
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ spring:
liquibase:
enabled: false

data:
redis:
host: ${SPRING_REDIS_HOST:localhost}
port: ${SPRING_REDIS_PORT:6379}

logging:
level:
org.hibernate.SQL: DEBUG
Expand Down