Skip to content

Commit 450d909

Browse files
committed
fix: 봉사시간 계산 테스트 날짜 수정
- 월요일이 주의 시작으로 계산되어 발생하는 테스트 에러 수정
1 parent cb62123 commit 450d909

File tree

4 files changed

+25
-36
lines changed

4 files changed

+25
-36
lines changed

.github/workflows/CI.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
DB_URL: ${{ secrets.DB_URL }}
1616
DB_USERNAME: ${{ secrets.DB_USERNAME }}
1717
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
18-
REDIS_HOST: ${{ secrets.REDIS_HOST }}
18+
REDIS_HOST: ${{ secrets.REDIS_HOST}}
1919
REDIS_PORT: ${{ secrets.REDIS_PORT }}
2020
NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }}
2121
NAVER_CLIENT_SECRET: ${{ secrets.NAVER_CLIENT_SECRET }}
@@ -35,11 +35,12 @@ jobs:
3535
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
3636
DEFAULT_IMG_URL: ${{ secrets.DEFAULT_IMG_URL }}
3737
APP_DEVELOP_MODE: ${{ secrets.APP_DEVELOP_MODE }}
38-
ELASTIC_URI: ${{ secrets.ELASTIC_URI }}
38+
ELASTIC_URI=localhost: ${{ secrets.ELASTIC_URI }}
3939
ELASTIC_USERNAME: ${{ secrets.ELASTIC_USERNAME }}
4040
ELASTIC_PASSWORD: ${{ secrets.ELASTIC_PASSWORD }}
4141
LOKI_URL: ${{ secrets.LOKI_URL }}
4242

43+
TESTCONTAINERS_REUSE_ENABLE: true
4344
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: /var/run/docker.sock
4445
DOCKER_HOST: unix:///var/run/docker.sock
4546

@@ -49,25 +50,15 @@ jobs:
4950
ports:
5051
- 6379:6379
5152

52-
mysql:
53-
image: mysql:8.0
54-
env:
55-
MYSQL_ROOT_PASSWORD: root
56-
MYSQL_DATABASE: test
57-
ports:
58-
- 3306:3306
59-
options: >-
60-
--health-cmd="mysqladmin ping -h localhost"
61-
--health-interval=10s
62-
--health-timeout=5s
63-
--health-retries=3
64-
6553
steps:
6654
- name: Github Repository 파일 불러오기
6755
uses: actions/checkout@v4
6856
with:
6957
fetch-depth: 0
7058

59+
- name: Set up Docker
60+
uses: docker/setup-buildx-action@v3
61+
7162
- name: JDK 21 버전 설치
7263
uses: actions/setup-java@v4
7364
with:
@@ -91,11 +82,6 @@ jobs:
9182
key: ${{ runner.os }}-sonar
9283
restore-keys: ${{ runner.os }}-sonar
9384

94-
- name: Docker 설정 확인
95-
run: |
96-
sudo chmod 666 /var/run/docker.sock
97-
docker info
98-
9985
- name: 빌드 권한 부여
10086
run: chmod +x ./gradlew
10187
shell: bash
@@ -112,7 +98,7 @@ jobs:
11298
uses: actions/github-script@v6
11399
with:
114100
github-token: ${{ github.TOKEN }}
115-
script: |
101+
script: |
116102
const pull_number = ${{ github.event.pull_request.number }}
117103
const updated_title = `[BUILD FAIL] ${{ github.event.pull_request.title }}`
118104
await github.rest.pulls.createReview({

src/test/java/com/somemore/domains/volunteerrecord/repository/VolunteerRecordRepositoryTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import org.springframework.transaction.annotation.Transactional;
99

1010
import java.math.BigDecimal;
11+
import java.time.DayOfWeek;
1112
import java.time.LocalDate;
13+
import java.time.temporal.TemporalAdjusters;
1214
import java.util.List;
1315
import java.util.UUID;
1416

@@ -51,7 +53,7 @@ void findTotalTopRankingWithTies() {
5153
void findVolunteerWeeklyRanking() {
5254

5355
// given
54-
LocalDate currentDate = LocalDate.now();
56+
LocalDate currentDate = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY));
5557

5658
// 이번 주 데이터
5759
volunteerRecordrepository.save(VolunteerRecord.create(UUID.randomUUID(), "이번주 봉사1", currentDate, 100));
@@ -85,7 +87,7 @@ void findVolunteerWeeklyRanking() {
8587
void fineVolunteerMonthlyRanking() {
8688

8789
// given
88-
LocalDate currentDate = LocalDate.now();
90+
LocalDate currentDate = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY));
8991

9092
// 이번 달 데이터
9193
volunteerRecordrepository.save(VolunteerRecord.create(UUID.randomUUID(), "이번달 봉사1", currentDate, 100));

src/test/java/com/somemore/domains/volunteerrecord/service/CalculateRankingServiceTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.transaction.annotation.Transactional;
1111

12+
import java.time.DayOfWeek;
1213
import java.time.LocalDate;
14+
import java.time.temporal.TemporalAdjusters;
1315
import java.util.UUID;
1416

1517
import static org.assertj.core.api.Assertions.assertThat;
@@ -56,7 +58,7 @@ void calculateTotalVolunteerRanking() {
5658
void calculateWeeklyVolunteerRanking() {
5759

5860
// given
59-
LocalDate currentDate = LocalDate.now();
61+
LocalDate currentDate = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY));
6062

6163
// 이번 주 데이터
6264
volunteerRecordRepository.save(VolunteerRecord.create(UUID.randomUUID(), "이번주봉사1", currentDate, 100));
@@ -89,7 +91,7 @@ void calculateWeeklyVolunteerRanking() {
8991
void calculateMonthlyVolunteerRanking() {
9092

9193
// given
92-
LocalDate currentDate = LocalDate.now();
94+
LocalDate currentDate = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY));
9395

9496
// 이번 달 데이터
9597
volunteerRecordRepository.save(VolunteerRecord.create(UUID.randomUUID(), "이번달봉사1", currentDate, 100));

src/test/java/com/somemore/support/TestContainerSupport.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,31 @@
1010
public abstract class TestContainerSupport {
1111

1212
private static final String REDIS_IMAGE = "redis:latest";
13-
private static final int REDIS_PORT = 6379;
13+
// private static final int REDIS_PORT = 6379;
1414
private static final String MYSQL_IMAGE = "mysql:8";
1515

16-
private static final GenericContainer REDIS;
16+
// private static final GenericContainer REDIS;
1717
private static final JdbcDatabaseContainer MYSQL;
1818

1919
static {
20-
REDIS = new GenericContainer(DockerImageName.parse(REDIS_IMAGE))
21-
.withExposedPorts(REDIS_PORT)
22-
.withReuse(true);
20+
// REDIS = new GenericContainer(DockerImageName.parse(REDIS_IMAGE))
21+
// .withExposedPorts(REDIS_PORT)
22+
// .withReuse(true);
2323
MYSQL = new MySQLContainer(MYSQL_IMAGE);
2424

25-
REDIS.start();
25+
// REDIS.start();
2626
MYSQL.start();
2727
}
2828

2929
@DynamicPropertySource
3030
public static void overrideProps(DynamicPropertyRegistry registry){
31-
registry.add("spring.data.redis.host", REDIS::getHost);
32-
registry.add("spring.data.redis.port", () -> String.valueOf(REDIS.getMappedPort(REDIS_PORT)));
33-
}
34-
@DynamicPropertySource
35-
public static void overrideProps2(DynamicPropertyRegistry registry){
31+
// registry.add("spring.data.redis.host", REDIS::getHost);
32+
// registry.add("spring.data.redis.port", () -> String.valueOf(REDIS.getMappedPort(REDIS_PORT)));
33+
3634
registry.add("spring.datasource.driver-class-name", MYSQL::getDriverClassName);
3735
registry.add("spring.datasource.url", MYSQL::getJdbcUrl);
3836
registry.add("spring.datasource.~username", MYSQL::getUsername);
3937
registry.add("spring.datasource.password", MYSQL::getPassword);
4038
}
39+
4140
}

0 commit comments

Comments
 (0)