2
2
{-# LANGUAGE OverloadedStrings #-}
3
3
4
4
module Test.Cardano.Db.Mock.Unit.Conway.Config.JsonbInSchema (
5
- configJsonbInSchemaTrue ,
6
- configJsonbInSchemaFalse ,
7
- configJsonbInSchemaShouldAddThenRemove ,
5
+ configRemoveJsonbFromSchemaEnabled ,
6
+ configRemoveJsonbFromSchemaDisabled ,
7
+ configJsonbInSchemaShouldRemoveThenAdd ,
8
8
) where
9
9
10
10
import qualified Cardano.Db as DB
11
11
import Cardano.DbSync.Config (SyncNodeConfig (.. ))
12
- import Cardano.DbSync.Config.Types (AddJsonbToSchemaConfig (.. ), SyncInsertOptions (.. ))
12
+ import Cardano.DbSync.Config.Types (RemoveJsonbFromSchemaConfig (.. ), SyncInsertOptions (.. ))
13
13
import Cardano.Mock.ChainSync.Server (IOManager ())
14
14
import Cardano.Prelude hiding (head )
15
15
import Test.Cardano.Db.Mock.Config
16
16
import Test.Cardano.Db.Mock.Validate
17
17
import Test.Tasty.HUnit (Assertion ())
18
18
19
- configJsonbInSchemaTrue :: IOManager -> [(Text , Text )] -> Assertion
20
- configJsonbInSchemaTrue ioManager metadata = do
19
+ configRemoveJsonbFromSchemaEnabled :: IOManager -> [(Text , Text )] -> Assertion
20
+ configRemoveJsonbFromSchemaEnabled ioManager metadata = do
21
21
syncNodeConfig <- mksNodeConfig
22
22
withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata
23
23
where
@@ -27,12 +27,12 @@ configJsonbInSchemaTrue ioManager metadata = do
27
27
assertEqQuery
28
28
dbSync
29
29
DB. queryJsonbInSchemaExists
30
- True
31
- " There should be jsonb data types in database if option is active "
30
+ False
31
+ " There should be no jsonb data types in database if option is enabled "
32
32
checkStillRuns dbSync
33
33
34
34
args = initCommandLineArgs {claFullMode = False }
35
- testLabel = " conwayConfigJsonbInSchemaTrue "
35
+ testLabel = " conwayConfigRemoveJsonbFromSchemaEnabled "
36
36
37
37
cfgDir = conwayConfigDir
38
38
@@ -42,11 +42,11 @@ configJsonbInSchemaTrue ioManager metadata = do
42
42
let dncInsertOptions' = dncInsertOptions initConfigFile
43
43
pure $
44
44
initConfigFile
45
- { dncInsertOptions = dncInsertOptions' {sioAddJsonbToSchema = AddJsonbToSchemaConfig True }
45
+ { dncInsertOptions = dncInsertOptions' {sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig True }
46
46
}
47
47
48
- configJsonbInSchemaFalse :: IOManager -> [(Text , Text )] -> Assertion
49
- configJsonbInSchemaFalse ioManager metadata = do
48
+ configRemoveJsonbFromSchemaDisabled :: IOManager -> [(Text , Text )] -> Assertion
49
+ configRemoveJsonbFromSchemaDisabled ioManager metadata = do
50
50
syncNodeConfig <- mksNodeConfig
51
51
withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata
52
52
where
@@ -56,12 +56,12 @@ configJsonbInSchemaFalse ioManager metadata = do
56
56
assertEqQuery
57
57
dbSync
58
58
DB. queryJsonbInSchemaExists
59
- False
60
- " There should be no jsonb types in database if option isn't active "
59
+ True
60
+ " There should be jsonb types in database if option is disabled "
61
61
checkStillRuns dbSync
62
62
63
63
args = initCommandLineArgs {claFullMode = False }
64
- testLabel = " conwayConfigJsonbInSchemaFalse "
64
+ testLabel = " conwayConfigRemoveJsonbFromSchemaDisabled "
65
65
66
66
cfgDir = conwayConfigDir
67
67
@@ -71,25 +71,30 @@ configJsonbInSchemaFalse ioManager metadata = do
71
71
let dncInsertOptions' = dncInsertOptions initConfigFile
72
72
pure $
73
73
initConfigFile
74
- { dncInsertOptions = dncInsertOptions' {sioAddJsonbToSchema = AddJsonbToSchemaConfig False }
74
+ { dncInsertOptions = dncInsertOptions' {sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False }
75
75
}
76
76
77
- configJsonbInSchemaShouldAddThenRemove :: IOManager -> [(Text , Text )] -> Assertion
78
- configJsonbInSchemaShouldAddThenRemove ioManager metadata = do
77
+ configJsonbInSchemaShouldRemoveThenAdd :: IOManager -> [(Text , Text )] -> Assertion
78
+ configJsonbInSchemaShouldRemoveThenAdd ioManager metadata = do
79
79
syncNodeConfig <- mksNodeConfig
80
80
withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata
81
81
where
82
82
action = \ _interpreter _mockServer dbSync -> do
83
83
startDBSync dbSync
84
84
threadDelay 7_000_000
85
+ assertEqQuery
86
+ dbSync
87
+ DB. queryJsonbInSchemaExists
88
+ False
89
+ " There should be no jsonb types in database if option has been enabled"
85
90
stopDBSync dbSync
86
91
let newDbSyncEnv =
87
92
dbSync
88
93
{ dbSyncConfig =
89
94
(dbSyncConfig dbSync)
90
95
{ dncInsertOptions =
91
96
(dncInsertOptions $ dbSyncConfig dbSync)
92
- { sioAddJsonbToSchema = AddJsonbToSchemaConfig False
97
+ { sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
93
98
}
94
99
}
95
100
}
@@ -98,13 +103,13 @@ configJsonbInSchemaShouldAddThenRemove ioManager metadata = do
98
103
assertEqQuery
99
104
dbSync
100
105
DB. queryJsonbInSchemaExists
101
- False
102
- " There should be no jsonb types in database if option has been set to False "
106
+ True
107
+ " There should be jsonb types in database if option has been disabled "
103
108
-- Expected to fail
104
109
checkStillRuns dbSync
105
110
106
111
args = initCommandLineArgs {claFullMode = False }
107
- testLabel = " configJsonbInSchemaShouldAddThenRemove "
112
+ testLabel = " configJsonbInSchemaShouldRemoveThenAdd "
108
113
109
114
cfgDir = conwayConfigDir
110
115
@@ -114,5 +119,5 @@ configJsonbInSchemaShouldAddThenRemove ioManager metadata = do
114
119
let dncInsertOptions' = dncInsertOptions initConfigFile
115
120
pure $
116
121
initConfigFile
117
- { dncInsertOptions = dncInsertOptions' {sioAddJsonbToSchema = AddJsonbToSchemaConfig True }
122
+ { dncInsertOptions = dncInsertOptions' {sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig True }
118
123
}
0 commit comments