Skip to content

Commit

Permalink
test: 스터디 히스토리 테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook02 committed Sep 25, 2024
1 parent d9eeb30 commit 8c908c9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class StudyHistory extends BaseEntity {
private String repositoryLink;

@Comment("수료 여부")
private boolean hasCompleted;
private Boolean hasCompleted;

@Builder(access = AccessLevel.PRIVATE)
private StudyHistory(Member student, Study study) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.gdschongik.gdsc.domain.study.domain;

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

import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.recruitment.domain.vo.Period;
import com.gdschongik.gdsc.helper.FixtureHelper;
import java.time.LocalDateTime;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

public class StudyHistoryTest {

FixtureHelper fixtureHelper = new FixtureHelper();

@Nested
class 스터디_히스토리_생성시 {

@Test
void 수료여부는_false이다() {
// given
Member student = fixtureHelper.createRegularMember(1L);
Member mentor = fixtureHelper.createRegularMember(2L);
LocalDateTime now = LocalDateTime.now();
Study study = fixtureHelper.createStudy(
mentor,
Period.createPeriod(now.plusDays(5), now.plusDays(10)),
Period.createPeriod(now.minusDays(5), now));

// when
StudyHistory studyHistory = StudyHistory.create(student, study);

// then
assertThat(studyHistory.getHasCompleted()).isFalse();
}
}

@Nested
class 스터디_수료시 {

@Test
void 수료여부는_true이다() {
// given
Member student = fixtureHelper.createRegularMember(1L);
Member mentor = fixtureHelper.createRegularMember(2L);
LocalDateTime now = LocalDateTime.now();
Study study = fixtureHelper.createStudy(
mentor,
Period.createPeriod(now.plusDays(5), now.plusDays(10)),
Period.createPeriod(now.minusDays(5), now));

StudyHistory studyHistory = StudyHistory.create(student, study);

// when
studyHistory.complete();

// then
assertThat(studyHistory.getHasCompleted()).isTrue();
}
}
}

0 comments on commit 8c908c9

Please sign in to comment.