User service is now non blocking
This commit is contained in:
@@ -3,6 +3,7 @@ package integration.services
|
||||
import be.vandewalleh.mainModule
|
||||
import be.vandewalleh.migrations.Migration
|
||||
import be.vandewalleh.services.UserService
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.amshove.kluent.*
|
||||
import org.junit.jupiter.api.*
|
||||
import org.kodein.di.Kodein
|
||||
@@ -36,34 +37,41 @@ class UserServiceTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
fun `test create user`() {
|
||||
val username = "hubert"
|
||||
val email = "a@a"
|
||||
val password = "password"
|
||||
println(userService.createUser(username, email, password))
|
||||
runBlocking {
|
||||
val username = "hubert"
|
||||
val email = "a@a"
|
||||
val password = "password"
|
||||
|
||||
val id = userService.getUserId(email)
|
||||
id `should not be` null
|
||||
userService.createUser(username, email, password)
|
||||
val id = userService.getUserId(email)
|
||||
id `should not be` null
|
||||
|
||||
userService.getUserInfo(id!!)!!.let {
|
||||
it.username `should be equal to` username
|
||||
it.email `should be equal to` email
|
||||
userService.getUserInfo(id!!)!!.let {
|
||||
it.username `should be equal to` username
|
||||
it.email `should be equal to` email
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
fun `test create same user`() {
|
||||
userService.createUser(username = "hubert", hashedPassword = "password", email = "a@a") `should be` null
|
||||
runBlocking {
|
||||
userService.createUser(username = "hubert", hashedPassword = "password", email = "a@a") `should be` null
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
fun `test delete user`() {
|
||||
val email = "a@a"
|
||||
val id = userService.getUserId(email)!!
|
||||
userService.deleteUser(id)
|
||||
runBlocking {
|
||||
val email = "a@a"
|
||||
val id = userService.getUserId(email)!!
|
||||
userService.deleteUser(id)
|
||||
|
||||
userService.getUserId(email) `should be` null
|
||||
userService.getUserInfo(id) `should be` null
|
||||
userService.getUserId(email) `should be` null
|
||||
userService.getUserInfo(id) `should be` null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user