-
Notifications
You must be signed in to change notification settings - Fork 1
feat: chapter clear cookie/#654 #657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,13 +103,13 @@ void execute_grantsChapterClearCookieReward() { | |
|
|
||
| assertThat(result.isChapterCleared()).isTrue(); | ||
| assertThat(result.nextChapterId()).isEqualTo(21L); | ||
| assertThat(userCaptor.getValue().totalCookie()).isEqualTo(1300); | ||
| assertThat(userCaptor.getValue().totalCookie()).isEqualTo(1100); | ||
| assertThat(historyCaptor.getValue().goodsActingCategory()).isEqualTo(GoodsActingCategory.ROADMAP_V2_CHAPTER_REWARD); | ||
| assertThat(historyCaptor.getValue().variation()).isEqualTo(300); | ||
| assertThat(historyCaptor.getValue().variation()).isEqualTo(100); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("마지막 챕터를 클리어하면 챕터 300과 섹션 3000 쿠키를 모두 지급한다") | ||
| @DisplayName("마지막 챕터를 클리어하면 챕터 100과 섹션 1000 쿠키를 모두 지급한다") | ||
| void execute_grantsChapterAndSectionClearCookieRewards() { | ||
| Actor actor = new Actor(1L); | ||
| ChoiceV2 correctChoice = new ChoiceV2(100L, 10L, "정답", true, 0); | ||
|
|
@@ -138,12 +138,12 @@ void execute_grantsChapterAndSectionClearCookieRewards() { | |
|
|
||
| assertThat(result.isChapterCleared()).isTrue(); | ||
| assertThat(result.nextChapterId()).isNull(); | ||
| assertThat(userCaptor.getValue().totalCookie()).isEqualTo(3800); | ||
| assertThat(userCaptor.getValue().totalCookie()).isEqualTo(1600); | ||
| assertThat(historyCaptor.getAllValues()) | ||
| .extracting(UserGoodsHistory::goodsActingCategory, UserGoodsHistory::variation) | ||
| .containsExactly( | ||
| org.assertj.core.groups.Tuple.tuple(GoodsActingCategory.ROADMAP_V2_CHAPTER_REWARD, 300), | ||
| org.assertj.core.groups.Tuple.tuple(GoodsActingCategory.ROADMAP_V2_SECTION_REWARD, 3000) | ||
| org.assertj.core.groups.Tuple.tuple(GoodsActingCategory.ROADMAP_V2_CHAPTER_REWARD, 100), | ||
| org.assertj.core.groups.Tuple.tuple(GoodsActingCategory.ROADMAP_V2_SECTION_REWARD, 1000) | ||
| ); | ||
|
Comment on lines
+141
to
147
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 테스트에 사용된 매직 넘버(1600, 100, 1000)는 코드의 가독성과 유지보수성을 저해합니다. 보상 값을 지역 상수로 선언하고, 이를 사용하여 예상 결과를 계산하는 방식으로 리팩터링하는 것을 권장합니다. 이렇게 하면 테스트의 의도가 명확해지고 향후 보상 값이 변경될 때 수정이 용이해집니다. final int chapterReward = 100;
final int sectionReward = 1000;
assertThat(userCaptor.getValue().totalCookie()).isEqualTo(500 + chapterReward + sectionReward);
assertThat(historyCaptor.getAllValues())
.extracting(UserGoodsHistory::goodsActingCategory, UserGoodsHistory::variation)
.containsExactly(
org.assertj.core.groups.Tuple.tuple(GoodsActingCategory.ROADMAP_V2_CHAPTER_REWARD, chapterReward),
org.assertj.core.groups.Tuple.tuple(GoodsActingCategory.ROADMAP_V2_SECTION_REWARD, sectionReward)
); |
||
| assertThat(progress.getIsCompleted()).isTrue(); | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
매직 넘버
1100은 테스트의 의도를 파악하기 어렵게 만듭니다. 초기 쿠키 값(1000)과 챕터 클리어 보상(100)을 더하는 형태로1000 + 100과 같이 명시적으로 작성하면 가독성과 유지보수성이 향상됩니다.