@@ -10,59 +10,82 @@ import kotlin.test.Test
10
10
11
11
class CrudTest {
12
12
@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 )))
15
16
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
+ }
20
21
21
22
@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
+ )
24
28
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" ))
28
32
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
+ }
32
36
33
37
@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
+ )
36
49
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" ))
40
53
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
+ }
44
57
45
58
@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
+ )
48
70
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" ))
52
74
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
+ }
56
78
57
79
@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 )))
60
83
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" ))
64
87
65
- val batch = database.getNextCrudTransaction()
66
- batch shouldBe null
67
- }
88
+ val batch = database.getNextCrudTransaction()
89
+ batch shouldBe null
90
+ }
68
91
}
0 commit comments