-
Notifications
You must be signed in to change notification settings - Fork 1
[test] 스터디 가입 요청/수락/거절 API 인수 테스트 추가 #54
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
base: feat/#25-impl-join-request-3
Are you sure you want to change the base?
[test] 스터디 가입 요청/수락/거절 API 인수 테스트 추가 #54
Conversation
- 스터디 가입 요청 - 스터디 가입 요청 수락 - 스터디 가입 요청 거절
| public SessionCookie 테스트_로그인(Long memberId) { | ||
| String sessionCookieValue = givenJsonRequest() | ||
| .body(memberId) | ||
| .when().post("/api/v1/test/sign-in") | ||
| .then().extract() | ||
| .cookie(sessionCookieName); | ||
|
|
||
| return new SessionCookie(sessionCookieName, sessionCookieValue); | ||
| } |
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.
테스트용 로그인 메서드입니다. 로그인 하면 쿠키 객체를 반환합니다.
쿠키 객체는 Step 메서드에서 다음과 같이 사용합니다.
public static ExtractableResponse<Response> 스터디_가입_요청(Long studyId, SessionCookie sessionCookie) {
return givenJsonRequest()
.cookie(sessionCookie.name(), sessionCookie.value())
.when().post("/api/v1/studies/{studyId}/join-requests", studyId)
.then().log().all().extract();
}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.
테스트 로그인할 때 어드민 로그인으로 안하고 별도의 테스트 로그인을 만드신건가요?
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.
네, 테스트 시나리오 상 어드민이 아니라 다른 Member가 로그인 할 수도 있을 것 같아서 만들었어요
jinny-l
left a comment
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.
에이프 고생 많으셨어요!
|
|
||
| @BeforeEach | ||
| @BeforeAll | ||
| void setUp() { | ||
| RestAssured.port = port; | ||
| } |
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.
@BeforeAll 이 더 좋을 것 같네요!
| public class JoinRequestFixture { | ||
|
|
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.
흐음.. 에이프랑 저랑 사용하는 픽스쳐 형태가 달라서 fixture 를 어떻게 관리하면 좋을지 논의해보면 좋긴 할 것 같네요
| var leader = memberRepository.save(리더()); | ||
| var member = memberRepository.save(멤버_01()); | ||
| var study = studyRepository.save(알고리즘_스터디()); |
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.
저는 API 요청을 날렸는데 에이프는 레포지토리에 직접 저장하셨군요
| private void 스터디_가입_요청이_생성되었는지_검증(ExtractableResponse<Response> response, Study study, Member member) { | ||
| var createdId = response.body().jsonPath().getLong("id"); | ||
| var created = joinRequestRepository.findById(createdId).get(); | ||
|
|
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.
저는 actual expected 이런식으로 네이밍했어요!
| public SessionCookie 테스트_로그인(Long memberId) { | ||
| String sessionCookieValue = givenJsonRequest() | ||
| .body(memberId) | ||
| .when().post("/api/v1/test/sign-in") | ||
| .then().extract() | ||
| .cookie(sessionCookieName); | ||
|
|
||
| return new SessionCookie(sessionCookieName, sessionCookieValue); | ||
| } |
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.
테스트 로그인할 때 어드민 로그인으로 안하고 별도의 테스트 로그인을 만드신건가요?
|
|
✨ Key changes
👋 To reviewers
Redis Test Container 추가
테스트용 로그인 Step 메서드 구현
테스트 규칙 제안
API 마다 테스트 class 만들기
스터디 가입 요청 API->CreateJoinRequestTestFixture는 해당 도메인에서만 사용하기
테스트 케이스
스터디 가입 요청 케이스
스터디 가입 요청 수락 케이스
스터디 가입 요청 거절 케이스