Skip to content

Commit

Permalink
feat: Entity 구현 및 Test 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Apr 15, 2024
1 parent 7eadd33 commit 5286667
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/site/katchup/springboot/entity/Member.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import jakarta.persistence.Id
class Member(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long,
val id: Long? = null,
val name: String,
val nickname: String,
val socialId: String,
Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/site/katchup/springboot/entity/MemberWorkSpace.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package site.katchup.springboot.entity

import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id

@Entity
class MemberWorkSpace(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long? = null,
val memberId: Long,
val workSpaceId: Long,
)
5 changes: 5 additions & 0 deletions src/main/kotlin/site/katchup/springboot/entity/SocialType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package site.katchup.springboot.entity

enum class SocialType {
GOOGLE,
}
16 changes: 16 additions & 0 deletions src/main/kotlin/site/katchup/springboot/entity/WorkSpace.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package site.katchup.springboot.entity

import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType.IDENTITY
import jakarta.persistence.Id

@Entity
class WorkSpace(
@Id
@GeneratedValue(strategy = IDENTITY)
val id: Long? = null,
val name: String,
val description: String,
val domain: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package site.katchup.springboot.repository

import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import site.katchup.springboot.entity.Member
import site.katchup.springboot.entity.SocialType

@RepositoryTest
class MemberRepositoryTest(
private val memberRepository: MemberRepository,
) : FunSpec({

test("신규 회원을 등록할 수 있다.") {
// given
val member = Member(
name = "name",
nickname = "nickname",
socialId = "socialId",
socialType = SocialType.GOOGLE,
lineMemo = "lineMemo",
workSpaceId = 1,
)
val savedMember = memberRepository.save(member)
val findMember = memberRepository.findById(savedMember.id!!).get()
findMember.id shouldBe savedMember.id
findMember.name shouldBe "name"
findMember.nickname shouldBe "nickname"
findMember.socialId shouldBe "socialId"
findMember.socialType shouldBe SocialType.GOOGLE
findMember.lineMemo shouldBe "lineMemo"
findMember.workSpaceId shouldBe 1
}
},)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package site.katchup.springboot.repository

import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
import org.springframework.context.annotation.ComponentScan
import org.springframework.test.context.ActiveProfiles

@DataJpaTest
@ActiveProfiles("test")
@ComponentScan("site.katchup.springboot.repository")
annotation class RepositoryTest()

0 comments on commit 5286667

Please sign in to comment.