File tree Expand file tree Collapse file tree 6 files changed +80
-1
lines changed
main/kotlin/site/katchup/springboot/entity
test/kotlin/site/katchup/springboot/repository Expand file tree Collapse file tree 6 files changed +80
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import jakarta.persistence.Id
1111class Member (
1212 @Id
1313 @GeneratedValue(strategy = GenerationType .IDENTITY )
14- val id : Long ,
14+ val id : Long? = null ,
1515 val name : String ,
1616 val nickname : String ,
1717 val socialId : String ,
Original file line number Diff line number Diff line change 1+ package site.katchup.springboot.entity
2+
3+ import jakarta.persistence.Entity
4+ import jakarta.persistence.GeneratedValue
5+ import jakarta.persistence.GenerationType
6+ import jakarta.persistence.Id
7+
8+ @Entity
9+ class MemberWorkSpace (
10+ @Id
11+ @GeneratedValue(strategy = GenerationType .IDENTITY )
12+ val id : Long? = null ,
13+ val memberId : Long ,
14+ val workSpaceId : Long ,
15+ )
Original file line number Diff line number Diff line change 1+ package site.katchup.springboot.entity
2+
3+ enum class SocialType {
4+ GOOGLE ,
5+ }
Original file line number Diff line number Diff line change 1+ package site.katchup.springboot.entity
2+
3+ import jakarta.persistence.Entity
4+ import jakarta.persistence.GeneratedValue
5+ import jakarta.persistence.GenerationType.IDENTITY
6+ import jakarta.persistence.Id
7+
8+ @Entity
9+ class WorkSpace (
10+ @Id
11+ @GeneratedValue(strategy = IDENTITY )
12+ val id : Long? = null ,
13+ val name : String ,
14+ val description : String ,
15+ val domain : String ,
16+ )
Original file line number Diff line number Diff line change 1+ package site.katchup.springboot.repository
2+
3+ import io.kotest.core.spec.style.FunSpec
4+ import io.kotest.matchers.shouldBe
5+ import site.katchup.springboot.entity.Member
6+ import site.katchup.springboot.entity.SocialType
7+
8+ @RepositoryTest
9+ class MemberRepositoryTest (
10+ private val memberRepository : MemberRepository ,
11+ ) : FunSpec({
12+
13+ test("신규 회원을 등록할 수 있다.") {
14+ // given
15+ val member = Member (
16+ name = "name",
17+ nickname = "nickname",
18+ socialId = "socialId",
19+ socialType = SocialType .GOOGLE ,
20+ lineMemo = "lineMemo",
21+ workSpaceId = 1,
22+ )
23+ val savedMember = memberRepository.save(member)
24+ val findMember = memberRepository.findById(savedMember.id!!).get()
25+ findMember.id shouldBe savedMember.id
26+ findMember.name shouldBe " name"
27+ findMember.nickname shouldBe " nickname"
28+ findMember.socialId shouldBe " socialId"
29+ findMember.socialType shouldBe SocialType .GOOGLE
30+ findMember.lineMemo shouldBe " lineMemo"
31+ findMember.workSpaceId shouldBe 1
32+ }
33+ },)
Original file line number Diff line number Diff line change 1+ package site.katchup.springboot.repository
2+
3+ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
4+ import org.springframework.context.annotation.ComponentScan
5+ import org.springframework.test.context.ActiveProfiles
6+
7+ @DataJpaTest
8+ @ActiveProfiles(" test" )
9+ @ComponentScan(" site.katchup.springboot.repository" )
10+ annotation class RepositoryTest ()
You can’t perform that action at this time.
0 commit comments