Skip to content

Conversation

@jj1kim
Copy link

@jj1kim jj1kim commented Oct 3, 2023

먼저 친절한 리뷰 감사드립니다.
아직 코드에서 테스트 중 "플레이리스트 좋아요 취소" 테스트는 fail 중인 상태입니다.
로그를 보면서 이유를 찾아봤더니, 이미 좋아요가 없는 상태에서 테스트 시 좋아요 취소 명령을 또 내려서 오류가 생긴 것 같더군요..
사실 바로 위의 테스트에서 좋아요를 넣기 때문에 그 데이터가 그대로 연결되리라고 생각했고, 세미나장님께서 알려주신 Transactional을 넣어도 문제는 해결되지 않았습니다.
다른 분들이 하신 걸 참고해서 해결해보려 했는데 대부분 데모유저를 만들어서 고유의 인증키를 생성하고, 그걸로 하나의 테스트 객체(?) 처럼 테스트를 진행해서 해결하셨더군요..
저처럼 테스트를 진행하는 방식에서 오류가 발생하는 것을 막을 수 있는 방법은 없을지 궁금합니다. 감사합니다.

(p.s. 몇몇 커밋 기록만 지우고 싶어서 커밋 삭제를 눌렀는데, 아예 작업했던 내용이 다 날아가버리더군요.. 로컬 레포 구석에다가 백업해둔 내용으로 급하게 다시 커밋들을 만들어서 올렸습니다.)

jj1kim and others added 22 commits September 11, 2023 14:31
# Conflicts:
#	src/main/kotlin/WebConfig.kt
#	src/main/kotlin/user/controller/UserController.kt
#	src/main/kotlin/user/controller/UserControllerV2.kt
#	src/main/kotlin/user/repository/UserRepository.kt
#	src/main/kotlin/user/service/UserServiceImpl.kt
#	src/test/kotlin/kotlin/KotlinTest.kt
Copy link
Member

@PFCJeong PFCJeong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

과제 꼼꼼히 잘해주셨네요~

@transactional을 붙이라 공지 드린 이유는, 생성된 데이터를 롤백하기 위함입니다.

delete 테스트는 좋아요 데이터가 없어서 실패하는 거라 @transactional이랑은 관계가 없습니다.

delete 테스트 성공을 위해서 좋아요 데이터를 미리 추가해야겠네요~

val songEntities = songRepository.findByTitleContainingWithArtists(keyword=keyword) //키워드를 포함한 노래의 songentitiy를 다 받아온다(리스트로)

return songEntities.map { sEntity-> //songEntity로서 곡에 대한 정보 전체를 controller로 넘겨 준다
Song(id = sEntity.id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개행을 조금 이쁘게 하면 좋을 것 같습니다.

import java.time.Instant

//이 캐시 레이어를 두는 방식에 대해서는 추후에 추가 공부 필요
class NormalCache<Key, Value>(private val ttl:Long) { //캐시 구현체 클래스를 따로 정의 -> 만들고 저장하는 등의 기능을 넣는다
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants