Skip to content

Commit

Permalink
Merge pull request #207 from yudonggeun/bug/issue200
Browse files Browse the repository at this point in the history
[Server] 버그 픽스 #200
  • Loading branch information
yudonggeun authored Jun 30, 2024
2 parents 8295af7 + 38f9c72 commit e1712c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package kpring.server.adapter.output.mongo

import kpring.server.adapter.output.mongo.entity.ServerEntity
import kpring.server.adapter.output.mongo.entity.ServerProfileEntity
import kpring.server.adapter.output.mongo.repository.ServerProfileRepository
import kpring.server.adapter.output.mongo.repository.ServerRepository
import kpring.server.application.port.output.UpdateServerPort
import kpring.server.domain.ServerProfile
Expand All @@ -15,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional
@Transactional
class UpdateServerPortMongoImpl(
val serverRepository: ServerRepository,
val serverProfileRepository: ServerProfileRepository,
val template: MongoTemplate,
) : UpdateServerPort {
override fun addUser(profile: ServerProfile) {
Expand All @@ -28,6 +31,8 @@ class UpdateServerPortMongoImpl(
.push("users", profile.userId),
ServerEntity::class.java,
)

serverProfileRepository.save(ServerProfileEntity(profile))
}

override fun inviteUser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kpring.server.application.port.output
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.collections.shouldContain
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.equals.shouldBeEqual
import kpring.server.util.testServer
import kpring.test.testcontainer.SpringTestContext
import org.springframework.boot.test.context.SpringBootTest
Expand All @@ -13,6 +14,7 @@ import org.springframework.test.context.ContextConfiguration
class UpdateServerPortTest(
val updateServerPort: UpdateServerPort,
val createServerPort: SaveServerPort,
val getServerProfilePort: GetServerProfilePort,
val getServerPort: GetServerPort,
) : DescribeSpec({

Expand All @@ -34,7 +36,7 @@ class UpdateServerPortTest(

it("가입 유저를 추가할 수 있다.") {
// given
val server = createServerPort.create(testServer(id = null))
val server = createServerPort.create(testServer(id = null, users = mutableSetOf()))
val userId = "userId"

server.registerInvitation(userId)
Expand All @@ -46,6 +48,9 @@ class UpdateServerPortTest(

// then
val result = getServerPort.get(server.id!!)

getServerProfilePort.getAll(server.id!!) shouldHaveSize server.users.size
result.users.size shouldBeEqual server.users.size
result.users shouldContain userId
result.invitedUserIds shouldHaveSize server.invitedUserIds.size
}
Expand Down

0 comments on commit e1712c6

Please sign in to comment.