Skip to content

Commit

Permalink
Fix: test 코드 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tape4 committed Jul 28, 2024
1 parent a73af83 commit dae3886
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CICD_DEVELOP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup MySQL
uses: mirromutth/[email protected]
with:
mysql database: 'kkijuk'
mysql database: 'testDB'
mysql user: 'test'
mysql password: 'testPW'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI_MVP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup MySQL
uses: mirromutth/[email protected]
with:
mysql database: 'kkijuk'
mysql database: 'testDB'
mysql user: 'test'
mysql password: 'testPW'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.transaction.Transactional;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -22,10 +24,15 @@
import umc.kkijuk.server.introduce.dto.QuestionDto;
import umc.kkijuk.server.introduce.service.IntroduceService;
import umc.kkijuk.server.introduce.service.MasterIntroduceService;
import umc.kkijuk.server.member.domain.MarketingAgree;
import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.member.domain.State;
import umc.kkijuk.server.member.service.MemberService;
import umc.kkijuk.server.recruit.domain.Recruit;
import umc.kkijuk.server.recruit.domain.RecruitStatus;
import umc.kkijuk.server.recruit.infrastructure.RecruitEntity;
import umc.kkijuk.server.recruit.infrastructure.RecruitJpaRepository;
import umc.kkijuk.server.recruit.service.port.RecruitRepository;

import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -51,6 +58,8 @@ class IntroduceControllerTest {
@Autowired
private IntroduceRepository introduceRepository;
@Autowired
private RecruitRepository recruitRepository;
@Autowired
private RecruitJpaRepository recruitJpaRepository;
@Autowired
private MockMvc mockMvc;
Expand All @@ -60,13 +69,25 @@ class IntroduceControllerTest {
private ObjectMapper objectMapper;
@Autowired
private QuestionRepository questionRepository;
@Autowired
private MemberService memberService;

private Member requestMember;

@BeforeEach
public void Init() {
Member member = new Member("[email protected]", "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", MarketingAgree.BOTH, State.ACTIVATE);
Long savedId = memberService.join(member);
requestMember = memberService.findOne(savedId);
}

@Test
@DisplayName("자기소개서 생성 테스트")
public void postIntro() throws Exception {
final int state = 1;

Recruit recruit = Recruit.builder()
.memberId(requestMember.getId())
.title("test-title")
.status(RecruitStatus.PLANNED)
.startTime(LocalDateTime.of(2024, 7, 19, 2, 30))
Expand All @@ -77,8 +98,8 @@ public void postIntro() throws Exception {
.active(true)
.build();

RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit));
Long recruitId = recruitEntity.toModel().getId();
Recruit savedRecruit = recruitRepository.save(recruit);
Long recruitId = savedRecruit.getId();

// 테스트용 질문 목록 생성
final List<QuestionDto> questions = Arrays.asList(
Expand Down Expand Up @@ -107,6 +128,7 @@ public void updateIntro() throws Exception {
final int state = 1;

Recruit recruit = Recruit.builder()
.memberId(requestMember.getId())
.title("test-title")
.status(RecruitStatus.PLANNED)
.startTime(LocalDateTime.of(2024, 7, 19, 2, 30))
Expand All @@ -117,7 +139,7 @@ public void updateIntro() throws Exception {
.active(true)
.build();

RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit));
RecruitEntity recruitEntity = RecruitEntity.from(recruitRepository.save(recruit));

Introduce introduce= introduceRepository.save(Introduce.builder()
.recruit(recruitEntity)
Expand Down Expand Up @@ -159,6 +181,7 @@ public void deleteIntro() throws Exception {
final int state = 1;

Recruit recruit = Recruit.builder()
.memberId(requestMember.getId())
.title("test-title")
.status(RecruitStatus.PLANNED)
.startTime(LocalDateTime.of(2024, 7, 19, 2, 30))
Expand All @@ -169,8 +192,7 @@ public void deleteIntro() throws Exception {
.active(true)
.build();

RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit));
Long recruitId = recruitEntity.toModel().getId();
RecruitEntity recruitEntity = RecruitEntity.from(recruitRepository.save(recruit));

// 테스트용 질문 목록 생성
final List<Question> questions = Arrays.asList(
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ spring.application.name=server

# spring data source
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/kkijuk?characterEncoding=UTF-8&serverTimezone=Asia/Seoul
spring.datasource.url=jdbc:mysql://localhost:3306/testDB?characterEncoding=UTF-8&serverTimezone=Asia/Seoul
spring.datasource.username=test
spring.datasource.password=testPW

Expand Down

0 comments on commit dae3886

Please sign in to comment.