Skip to content

Commit 2b55a00

Browse files
committed
Fix the unit tests of sqllin-dsl
1 parent 8b286c5 commit 2b55a00

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class AndroidTest {
7575
fun testPrimitiveTypeForKSP() = commonTest.testPrimitiveTypeForKSP()
7676

7777
@Test
78-
fun testNullInsertAndSelect() = commonTest.testNullInsertAndSelect()
78+
fun testNullValue() = commonTest.testNullValue()
7979

8080
@Before
8181
fun setUp() {

sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -369,43 +369,43 @@ class CommonBasicTest(private val path: DatabasePath) {
369369
assertEquals(outerJoinStatementWithOn?.getResults()?.size, books.size)
370370
}
371371

372-
fun testConcurrency() = runBlocking(Dispatchers.Default) {
373-
val book1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = 16.96)
374-
val book2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = 19.95)
375-
val database = Database(getDefaultDBConfig(), true)
376-
launch {
377-
var statement: SelectStatement<Book>? = null
378-
database suspendedScope {
379-
statement = BookTable { table ->
380-
table INSERT listOf(book1, book2)
381-
table SELECT X
382-
}
383-
}
384-
372+
fun testConcurrency() = Database(getDefaultDBConfig(), true).databaseAutoClose { database ->
373+
runBlocking(Dispatchers.Default) {
374+
val book1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = 16.96)
375+
val book2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = 19.95)
385376
launch {
386-
val book1NewPrice = 18.96
387-
val book2NewPrice = 21.95
388-
val newBook1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = book1NewPrice)
389-
val newBook2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = book2NewPrice)
390-
var newResult: SelectStatement<Book>? = null
377+
var statement: SelectStatement<Book>? = null
391378
database suspendedScope {
392-
newResult = transaction {
393-
BookTable { table ->
394-
table UPDATE SET { price = book1NewPrice } WHERE (name EQ book1.name AND (price EQ book1.price))
395-
table UPDATE SET { price = book2NewPrice } WHERE (name EQ book2.name AND (price EQ book2.price))
396-
table SELECT X
379+
statement = BookTable { table ->
380+
table INSERT listOf(book1, book2)
381+
table SELECT X
382+
}
383+
}
384+
385+
launch {
386+
val book1NewPrice = 18.96
387+
val book2NewPrice = 21.95
388+
val newBook1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = book1NewPrice)
389+
val newBook2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = book2NewPrice)
390+
var newResult: SelectStatement<Book>? = null
391+
database suspendedScope {
392+
newResult = transaction {
393+
BookTable { table ->
394+
table UPDATE SET { price = book1NewPrice } WHERE (name EQ book1.name AND (price EQ book1.price))
395+
table UPDATE SET { price = book2NewPrice } WHERE (name EQ book2.name AND (price EQ book2.price))
396+
table SELECT X
397+
}
397398
}
398399
}
400+
401+
assertEquals(true, newResult!!.getResults().any { it == newBook1 })
402+
assertEquals(true, newResult!!.getResults().any { it == newBook2 })
399403
}
400404

401-
assertEquals(true, newResult!!.getResults().any { it == newBook1 })
402-
assertEquals(true, newResult!!.getResults().any { it == newBook2 })
405+
assertEquals(true, statement!!.getResults().any { it == book1 })
406+
assertEquals(true, statement!!.getResults().any { it == book2 })
403407
}
404-
405-
assertEquals(true, statement!!.getResults().any { it == book1 })
406-
assertEquals(true, statement!!.getResults().any { it == book2 })
407408
}
408-
Unit
409409
}
410410

411411
fun testPrimitiveTypeForKSP() {
@@ -428,7 +428,7 @@ class CommonBasicTest(private val path: DatabasePath) {
428428
}
429429
}
430430

431-
fun testNullInsertAndSelect() {
431+
fun testNullValue() {
432432
val config = DatabaseConfiguration(
433433
name = DATABASE_NAME,
434434
path = path,
@@ -487,9 +487,9 @@ class CommonBasicTest(private val path: DatabasePath) {
487487
}
488488
val result2 = selectStatement.getResults().first()
489489
assertEquals(1, selectStatement.getResults().size)
490-
assertEquals(8, result1.paramInt)
491-
assertEquals(null, result1.paramString)
492-
assertEquals(8.8, result1.paramDouble)
490+
assertEquals(8, result2.paramInt)
491+
assertEquals(null, result2.paramString)
492+
assertEquals(8.8, result2.paramDouble)
493493
}
494494
}
495495

sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class JvmTest {
6666
fun testPrimitiveTypeForKSP() = commonTest.testPrimitiveTypeForKSP()
6767

6868
@Test
69-
fun testNullInsertAndSelect() = commonTest.testNullInsertAndSelect()
69+
fun testNullValue() = commonTest.testNullValue()
7070

7171
@BeforeTest
7272
fun setUp() {

sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class NativeTest {
6969
fun testPrimitiveTypeForKSP() = commonTest.testPrimitiveTypeForKSP()
7070

7171
@Test
72-
fun testNullInsertAndSelect() = commonTest.testNullInsertAndSelect()
72+
fun testNullValue() = commonTest.testNullValue()
7373

7474
@BeforeTest
7575
fun setUp() {

0 commit comments

Comments
 (0)