Nomantis Knight
03/23/2022, 10:25 PMclass ProjectRepositoryTest {
companion object {
val database = Database.connect("jdbc:sqlite:file:test?mode=memory&cache=shared", "org.sqlite.JDBC")
val projectRepository = ProjectRepository(database)
const val initialNumberOfProjects = 10
@BeforeAll
@JvmStatic
fun setUp() {
database.transactionManager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
database.transactionManager.defaultRepetitionAttempts = 1
}
}
@BeforeEach
fun setUpEach() {
transaction(database) {
addLogger(StdOutSqlLogger)
SchemaUtils.create(ProjectsTable)
}
}
@Test
fun testGetAllProjects() {
println("Creating initial projects.")
transaction(database) {
addLogger(StdOutSqlLogger)
repeat(initialNumberOfProjects) { i ->
println("\tCreated project $i.")
ProjectEntity.new {
name = "Project $i"
description = "Description $i"
archived = 0b0
}
}
}
...
}
@AfterEach
fun tearDown() {
transaction(database) {
SchemaUtils.drop(ProjectsTable)
}
}
}
I'm getting a database does not exist exception, saying that the Projects table doesn't exist. What am I doing wrong?Leonid Yavorskyi
03/24/2022, 7:35 AM@BeforeAll
blockNomantis Knight
03/24/2022, 9:15 AMNomantis Knight
03/24/2022, 9:17 AMspand
03/24/2022, 1:32 PMsetUpEach()
.Nomantis Knight
03/24/2022, 4:32 PMjdbc:sqlite:file:test?mode=memory&cache=shared
, then it does not work, and throws the error I said above. If you use jdbc:sqlite:test:?mode=memory&cache=shared
though, then it works no problem.