File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed
src/test/kotlin/infrastructure/database Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -15,17 +15,33 @@ import io.kotest.matchers.shouldNotBe
1515
1616class TestMongo : StringSpec ({
1717
18- " Test user operations on mongo db" {
19- withMongo {
20- val mockUser = User ("1234", "MockPassword !")
21-
22- val mongoClient = MongoClient ("mongodb://localhost:27017")
18+ val mockUser = User ("1234", "MockPassword !")
2319
20+ " Test user creation on mongo db" {
21+ withMongo {
22+ val mongoClient = MongoClient ("mongodb://localhost:27017").also {
23+ it.getDatabase("user_management").drop()
24+ }
2425 mongoClient.createUser(mockUser) shouldNotBe null
26+ }
27+ }
2528
29+ " Test user deletion on mongo db" {
30+ withMongo {
31+ val mongoClient = MongoClient ("mongodb://localhost:27017").also {
32+ it.getDatabase("user_management").drop()
33+ }
34+ mongoClient.createUser(mockUser)
2635 mongoClient.deleteUser(mockUser.userId) shouldBe true
36+ }
37+ }
2738
28- mongoClient.createUser(mockUser) shouldNotBe null
39+ " Test user retrieve on mongo db" {
40+ withMongo {
41+ val mongoClient = MongoClient ("mongodb://localhost:27017").also {
42+ it.getDatabase("user_management").drop()
43+ }
44+ mongoClient.createUser(mockUser)
2945 mongoClient.getUser(mockUser.userId).also {
3046 it shouldNotBe null
3147 it?.userId shouldBe mockUser.userId
You can’t perform that action at this time.
0 commit comments