test: 動かないテストがあったので修正

This commit is contained in:
usbharu 2024-09-10 21:34:45 +09:00
parent 9daf79904b
commit fa66ccaa0c
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
2 changed files with 6 additions and 7 deletions

View File

@ -10,7 +10,6 @@ import kotlinx.coroutines.test.runTest
import org.assertj.db.api.Assertions.assertThat import org.assertj.db.api.Assertions.assertThat
import org.jetbrains.exposed.sql.transactions.TransactionManager import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.InjectMocks import org.mockito.InjectMocks
import org.mockito.Mock import org.mockito.Mock
@ -26,7 +25,6 @@ import kotlin.test.assertEquals
import kotlin.test.assertNotNull import kotlin.test.assertNotNull
import kotlin.test.assertNull import kotlin.test.assertNull
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@ExtendWith(MockitoExtension::class) @ExtendWith(MockitoExtension::class)
class ExposedActorInstanceRelationshipRepositoryTest : AbstractRepositoryTest(ActorInstanceRelationships) { class ExposedActorInstanceRelationshipRepositoryTest : AbstractRepositoryTest(ActorInstanceRelationships) {
@ -328,10 +326,6 @@ class ExposedActorInstanceRelationshipRepositoryTest : AbstractRepositoryTest(Ac
dbSetup(to = dataSource) { dbSetup(to = dataSource) {
execute(disableReferenceIntegrityConstraints) execute(disableReferenceIntegrityConstraints)
insertInto(ActorInstanceRelationships.tableName) {
columns(ActorInstanceRelationships.columns)
values(1, 1, true, true, true)
}
}.launch() }.launch()
val actorInstanceRelationship = ActorInstanceRelationship( val actorInstanceRelationship = ActorInstanceRelationship(
@ -350,6 +344,10 @@ class ExposedActorInstanceRelationshipRepositoryTest : AbstractRepositoryTest(Ac
dbSetup(to = dataSource) { dbSetup(to = dataSource) {
execute(disableReferenceIntegrityConstraints) execute(disableReferenceIntegrityConstraints)
insertInto(ActorInstanceRelationships.tableName) {
columns(ActorInstanceRelationships.columns)
values(1, 1, true, true, true)
}
}.launch() }.launch()
val actorInstanceRelationship = ActorInstanceRelationship( val actorInstanceRelationship = ActorInstanceRelationship(

View File

@ -41,7 +41,7 @@ abstract class AbstractRepositoryTest(private val exposedTable: org.jetbrains.ex
fun setUp() { fun setUp() {
flyway.clean() flyway.clean()
flyway.migrate() flyway.migrate()
transaction = TransactionManager.currentOrNew(Connection.TRANSACTION_READ_UNCOMMITTED) transaction = TransactionManager.manager.newTransaction(Connection.TRANSACTION_READ_UNCOMMITTED)
change = Changes(assertTable) change = Changes(assertTable)
} }
@ -51,6 +51,7 @@ abstract class AbstractRepositoryTest(private val exposedTable: org.jetbrains.ex
execute(Operations.sql("SET REFERENTIAL_INTEGRITY TRUE")) execute(Operations.sql("SET REFERENTIAL_INTEGRITY TRUE"))
} }
transaction.rollback() transaction.rollback()
transaction.close()
} }
companion object { companion object {