@@ -10,59 +10,82 @@ import kotlin.test.Test
1010
1111class CrudTest {
1212 @Test
13- fun includeMetadata () = databaseTest {
14- database.updateSchema(Schema (Table (" lists" , listOf (Column .text(" name" )), includeMetadata = true )))
13+ fun includeMetadata () =
14+ databaseTest {
15+ database.updateSchema(Schema (Table (" lists" , listOf (Column .text(" name" )), includeMetadata = true )))
1516
16- database.execute(" INSERT INTO lists (id, name, _metadata) VALUES (uuid(), ?, ?)" , listOf (" entry" , " so meta" ))
17- val batch = database.getNextCrudTransaction()
18- batch!! .crud[0 ].metadata shouldBe " so meta"
19- }
17+ database.execute(" INSERT INTO lists (id, name, _metadata) VALUES (uuid(), ?, ?)" , listOf (" entry" , " so meta" ))
18+ val batch = database.getNextCrudTransaction()
19+ batch!! .crud[0 ].metadata shouldBe " so meta"
20+ }
2021
2122 @Test
22- fun includeOldValues () = databaseTest {
23- database.updateSchema(Schema (Table (" lists" , listOf (Column .text(" name" ), Column .text(" content" )), includeOld = IncludeOldOptions ())))
23+ fun includeOldValues () =
24+ databaseTest {
25+ database.updateSchema(
26+ Schema (Table (" lists" , listOf (Column .text(" name" ), Column .text(" content" )), includeOld = IncludeOldOptions ())),
27+ )
2428
25- database.execute(" INSERT INTO lists (id, name, content) VALUES (uuid(), ?, ?)" , listOf (" entry" , " content" ))
26- database.execute(" DELETE FROM ps_crud" )
27- database.execute(" UPDATE lists SET name = ?" , listOf (" new name" ))
29+ database.execute(" INSERT INTO lists (id, name, content) VALUES (uuid(), ?, ?)" , listOf (" entry" , " content" ))
30+ database.execute(" DELETE FROM ps_crud" )
31+ database.execute(" UPDATE lists SET name = ?" , listOf (" new name" ))
2832
29- val batch = database.getNextCrudTransaction()
30- batch!! .crud[0 ].oldData shouldBe mapOf (" name" to " entry" , " content" to " content" )
31- }
33+ val batch = database.getNextCrudTransaction()
34+ batch!! .crud[0 ].oldData shouldBe mapOf (" name" to " entry" , " content" to " content" )
35+ }
3236
3337 @Test
34- fun includeOldValuesWithFilter () = databaseTest {
35- database.updateSchema(Schema (Table (" lists" , listOf (Column .text(" name" ), Column .text(" content" )), includeOld = IncludeOldOptions (columnFilter = listOf (" name" )))))
38+ fun includeOldValuesWithFilter () =
39+ databaseTest {
40+ database.updateSchema(
41+ Schema (
42+ Table (
43+ " lists" ,
44+ listOf (Column .text(" name" ), Column .text(" content" )),
45+ includeOld = IncludeOldOptions (columnFilter = listOf (" name" )),
46+ ),
47+ ),
48+ )
3649
37- database.execute(" INSERT INTO lists (id, name, content) VALUES (uuid(), ?, ?)" , listOf (" entry" , " content" ))
38- database.execute(" DELETE FROM ps_crud" )
39- database.execute(" UPDATE lists SET name = ?, content = ?" , listOf (" new name" , " new content" ))
50+ database.execute(" INSERT INTO lists (id, name, content) VALUES (uuid(), ?, ?)" , listOf (" entry" , " content" ))
51+ database.execute(" DELETE FROM ps_crud" )
52+ database.execute(" UPDATE lists SET name = ?, content = ?" , listOf (" new name" , " new content" ))
4053
41- val batch = database.getNextCrudTransaction()
42- batch!! .crud[0 ].oldData shouldBe mapOf (" name" to " entry" )
43- }
54+ val batch = database.getNextCrudTransaction()
55+ batch!! .crud[0 ].oldData shouldBe mapOf (" name" to " entry" )
56+ }
4457
4558 @Test
46- fun includeOldValuesWhenChanged () = databaseTest {
47- database.updateSchema(Schema (Table (" lists" , listOf (Column .text(" name" ), Column .text(" content" )), includeOld = IncludeOldOptions (onlyWhenChanged = true ))))
59+ fun includeOldValuesWhenChanged () =
60+ databaseTest {
61+ database.updateSchema(
62+ Schema (
63+ Table (
64+ " lists" ,
65+ listOf (Column .text(" name" ), Column .text(" content" )),
66+ includeOld = IncludeOldOptions (onlyWhenChanged = true ),
67+ ),
68+ ),
69+ )
4870
49- database.execute(" INSERT INTO lists (id, name, content) VALUES (uuid(), ?, ?)" , listOf (" entry" , " content" ))
50- database.execute(" DELETE FROM ps_crud" )
51- database.execute(" UPDATE lists SET name = ?" , listOf (" new name" ))
71+ database.execute(" INSERT INTO lists (id, name, content) VALUES (uuid(), ?, ?)" , listOf (" entry" , " content" ))
72+ database.execute(" DELETE FROM ps_crud" )
73+ database.execute(" UPDATE lists SET name = ?" , listOf (" new name" ))
5274
53- val batch = database.getNextCrudTransaction()
54- batch!! .crud[0 ].oldData shouldBe mapOf (" name" to " entry" )
55- }
75+ val batch = database.getNextCrudTransaction()
76+ batch!! .crud[0 ].oldData shouldBe mapOf (" name" to " entry" )
77+ }
5678
5779 @Test
58- fun ignoreEmptyUpdate () = databaseTest {
59- database.updateSchema(Schema (Table (" lists" , listOf (Column .text(" name" ), Column .text(" content" )), ignoreEmptyUpdate = true )))
80+ fun ignoreEmptyUpdate () =
81+ databaseTest {
82+ database.updateSchema(Schema (Table (" lists" , listOf (Column .text(" name" ), Column .text(" content" )), ignoreEmptyUpdate = true )))
6083
61- database.execute(" INSERT INTO lists (id, name, content) VALUES (uuid(), ?, ?)" , listOf (" entry" , " content" ))
62- database.execute(" DELETE FROM ps_crud" )
63- database.execute(" UPDATE lists SET name = ?" , listOf (" entry" ))
84+ database.execute(" INSERT INTO lists (id, name, content) VALUES (uuid(), ?, ?)" , listOf (" entry" , " content" ))
85+ database.execute(" DELETE FROM ps_crud" )
86+ database.execute(" UPDATE lists SET name = ?" , listOf (" entry" ))
6487
65- val batch = database.getNextCrudTransaction()
66- batch shouldBe null
67- }
88+ val batch = database.getNextCrudTransaction()
89+ batch shouldBe null
90+ }
6891}
0 commit comments