Skip to content

Commit

Permalink
test: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akrck02 committed Dec 5, 2024
1 parent e892d2a commit 814df98
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
33 changes: 0 additions & 33 deletions src/main/kotlin/org/akrck02/valhalla/core/dal/Main.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
package org.akrck02.valhalla.core.dal.service.project

class UserDataAccessTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.akrck02.valhalla.core.dal.service.user

import com.mongodb.kotlin.client.coroutine.MongoDatabase
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.akrck02.valhalla.core.dal.configuration.getCurrentDatabaseConfiguration
import org.akrck02.valhalla.core.dal.database.Databases
import org.akrck02.valhalla.core.dal.database.Mongo
import org.akrck02.valhalla.core.sdk.model.exception.ServiceException
import org.akrck02.valhalla.core.sdk.model.user.User
import org.junit.jupiter.api.BeforeEach
import kotlin.test.Test

class UserDataAccessTest {

@BeforeEach
fun resetDatabase() {
runBlocking {
val mongo = Mongo().also { it.connect(getCurrentDatabaseConfiguration()) }
val database: MongoDatabase? = mongo.client?.getDatabase(databaseName = Databases.ValhallaTest.id)
database ?: throw ServiceException(message = "Cannot connect to database")
}
}

@Test
fun userRegisterTest() {
runBlocking {
val mongo = Mongo().also { it.connect(getCurrentDatabaseConfiguration()) }
val database: MongoDatabase? = mongo.client?.getDatabase(databaseName = Databases.ValhallaTest.id)
launch {
database ?: throw ServiceException(message = "Database not connected!")
registerUser(
database,
User(
id = null,
username = "akrck01",
email = "akrck02@gmail.com",
password = "#PasswordisHereLoL#?"
)
)
}

}
}
}

0 comments on commit 814df98

Please sign in to comment.