Skip to content
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

Kotest "Please call Database.connect() before using this code" 에러 #2

Open
khcho0125 opened this issue Apr 30, 2023 · 0 comments
Open
Assignees
Labels
record 과제를 진행하며 마주친 문제입니다.

Comments

@khcho0125
Copy link
Owner

KotestMockk를 사용해 테스트 코드를 작성하려 했습니다.
빠르게 테스트 코드를 작성하고 실행을 해보았는데....

디스패처 에러와 데이터베이스와 연결이 안 되었다고 합니다.

문제의 원인은 UseCase를 호출할 때 사용된 dbQuery 함수때문이였습니다.

트랜잭션을 호출해 TransactionManager에 접근됩니다.

dbQuery 인자를 꺼내야 하는 상황에서 다행히 Mockk 함수인 firstArg로 가져올 수 있었습니다.

image

Transaction을 Mock으로 바꿔친 후 실행 로직을 dbQuery밖으로 꺼내오는 동작

@khcho0125 khcho0125 added the record 과제를 진행하며 마주친 문제입니다. label Apr 30, 2023
@khcho0125 khcho0125 self-assigned this Apr 30, 2023
@khcho0125 khcho0125 pinned this issue Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
record 과제를 진행하며 마주친 문제입니다.
Projects
None yet
Development

No branches or pull requests

1 participant