Skip to content

Commit

Permalink
release: 1.4.0 (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored Feb 20, 2025
2 parents c013fae + d792372 commit f67f6e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/org/gitanimals/render/domain/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class User(
?: throw IllegalArgumentException("Cannot find persona by id \"$personaId\"")

this.personas.remove(persona)
check(personas.isNotEmpty()) { "Cannot delete last pet user must have least 1 pet. \"$name\"" }

DomainEventPublisher.publish(
PersonaDeleted(
userId = id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ internal class UserServiceTest(
}) {

private companion object {
val user = User.newUser("devxb", mapOf())
val user = User.newUser("devxb", mapOf(2025 to 1000))
}
}
14 changes: 13 additions & 1 deletion src/test/kotlin/org/gitanimals/render/domain/UserTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gitanimals.render.domain

import io.kotest.assertions.throwables.shouldNotThrowAny
import io.kotest.assertions.throwables.shouldThrowExactly
import io.kotest.assertions.throwables.shouldThrowWithMessage
import io.kotest.core.annotation.DisplayName
import io.kotest.core.spec.style.DescribeSpec
Expand Down Expand Up @@ -142,7 +143,7 @@ internal class UserTest(

describe("deletePersona 메소드는") {
context("personaId를 받으면,") {
val user = User.newUser("devxb", mapOf())
val user = User.newUser("devxb", mapOf(2025 to 1000))
val personaId = user.personas[0].id

it("persona를 삭제하고 PersonaDeleted 이벤트를 발행한다.") {
Expand All @@ -151,6 +152,17 @@ internal class UserTest(
domainEventHolder.eventsShouldBe(PersonaDeleted::class, 1)
}
}

context("persona 수가 하나라면") {
val user = User.newUser("devxb", mapOf())
val personaId = user.personas[0].id

it("IllegalStateException을 던진다") {
shouldThrowExactly<IllegalStateException> {
user.deletePersona(personaId)
}
}
}
}
}) {
private companion object {
Expand Down

0 comments on commit f67f6e2

Please sign in to comment.