@@ -74,7 +74,7 @@ func TestFirewallDBMigration(t *testing.T) {
74
74
// The assertKvStoreMigrationResults function will currently assert that
75
75
// the migrated kv stores entries in the SQLDB match the original kv
76
76
// stores entries in the BoltDB.
77
- assertKvStoreMigrationResults := func (t * testing.T , store * SQLDB ,
77
+ assertKvStoreMigrationResults := func (t * testing.T , store * sqlc. Queries ,
78
78
kvEntries []* kvEntry ) {
79
79
80
80
var (
@@ -87,9 +87,7 @@ func TestFirewallDBMigration(t *testing.T) {
87
87
getRuleID := func (ruleName string ) int64 {
88
88
ruleID , ok := ruleIDs [ruleName ]
89
89
if ! ok {
90
- ruleID , err = store .db .GetRuleID (
91
- ctx , ruleName ,
92
- )
90
+ ruleID , err = store .GetRuleID (ctx , ruleName )
93
91
require .NoError (t , err )
94
92
95
93
ruleIDs [ruleName ] = ruleID
@@ -101,7 +99,7 @@ func TestFirewallDBMigration(t *testing.T) {
101
99
getGroupID := func (groupAlias []byte ) int64 {
102
100
groupID , ok := groupIDs [string (groupAlias )]
103
101
if ! ok {
104
- groupID , err = store .db . GetSessionIDByAlias (
102
+ groupID , err = store .GetSessionIDByAlias (
105
103
ctx , groupAlias ,
106
104
)
107
105
require .NoError (t , err )
@@ -115,7 +113,7 @@ func TestFirewallDBMigration(t *testing.T) {
115
113
getFeatureID := func (featureName string ) int64 {
116
114
featureID , ok := featureIDs [featureName ]
117
115
if ! ok {
118
- featureID , err = store .db . GetFeatureID (
116
+ featureID , err = store .GetFeatureID (
119
117
ctx , featureName ,
120
118
)
121
119
require .NoError (t , err )
@@ -126,10 +124,10 @@ func TestFirewallDBMigration(t *testing.T) {
126
124
return featureID
127
125
}
128
126
129
- // First we extract all migrated kv entries from the SQLDB ,
127
+ // First we extract all migrated kv entries from the store ,
130
128
// in order to be able to compare them to the original kv
131
129
// entries, to ensure that the migration was successful.
132
- sqlKvEntries , err := store .db . ListAllKVStoresRecords (ctx )
130
+ sqlKvEntries , err := store .ListAllKVStoresRecords (ctx )
133
131
require .NoError (t , err )
134
132
require .Equal (t , len (kvEntries ), len (sqlKvEntries ))
135
133
@@ -145,7 +143,7 @@ func TestFirewallDBMigration(t *testing.T) {
145
143
ruleID := getRuleID (entry .ruleName )
146
144
147
145
if entry .groupAlias .IsNone () {
148
- sqlVal , err := store .db . GetGlobalKVStoreRecord (
146
+ sqlVal , err := store .GetGlobalKVStoreRecord (
149
147
ctx ,
150
148
sqlc.GetGlobalKVStoreRecordParams {
151
149
Key : entry .key ,
@@ -163,7 +161,7 @@ func TestFirewallDBMigration(t *testing.T) {
163
161
groupAlias := entry .groupAlias .UnwrapOrFail (t )
164
162
groupID := getGroupID (groupAlias [:])
165
163
166
- v , err := store .db . GetGroupKVStoreRecord (
164
+ v , err := store .GetGroupKVStoreRecord (
167
165
ctx ,
168
166
sqlc.GetGroupKVStoreRecordParams {
169
167
Key : entry .key ,
@@ -188,7 +186,7 @@ func TestFirewallDBMigration(t *testing.T) {
188
186
entry .featureName .UnwrapOrFail (t ),
189
187
)
190
188
191
- sqlVal , err := store .db . GetFeatureKVStoreRecord (
189
+ sqlVal , err := store .GetFeatureKVStoreRecord (
192
190
ctx ,
193
191
sqlc.GetFeatureKVStoreRecordParams {
194
192
Key : entry .key ,
@@ -219,14 +217,14 @@ func TestFirewallDBMigration(t *testing.T) {
219
217
// BoltDB. It also asserts that the SQL DB does not contain any other
220
218
// privacy pairs than the expected ones.
221
219
assertPrivacyMapperMigrationResults := func (t * testing.T ,
222
- sqlStore * SQLDB , privPairs privacyPairs ) {
220
+ sqlStore * sqlc. Queries , privPairs privacyPairs ) {
223
221
224
222
var totalExpectedPairs , totalPairs int
225
223
226
224
// First assert that the SQLDB contains the expected privacy
227
225
// pairs.
228
226
for groupID , groupPairs := range privPairs {
229
- storePairs , err := sqlStore .db . GetAllPrivacyPairs (
227
+ storePairs , err := sqlStore .GetAllPrivacyPairs (
230
228
ctx , groupID ,
231
229
)
232
230
require .NoError (t , err )
@@ -246,14 +244,13 @@ func TestFirewallDBMigration(t *testing.T) {
246
244
}
247
245
}
248
246
249
- // Then assert that SQLDB doesn't contain any other privacy
247
+ // Then assert that store doesn't contain any other privacy
250
248
// pairs than the expected ones.
251
- queries := sqlc .NewForType (sqlStore , sqlStore .BackendType )
252
- sessions , err := queries .ListSessions (ctx )
249
+ sessions , err := sqlStore .ListSessions (ctx )
253
250
require .NoError (t , err )
254
251
255
252
for _ , dbSession := range sessions {
256
- sessionPairs , err := sqlStore .db . GetAllPrivacyPairs (
253
+ sessionPairs , err := sqlStore .GetAllPrivacyPairs (
257
254
ctx , dbSession .ID ,
258
255
)
259
256
if errors .Is (err , sql .ErrNoRows ) {
@@ -272,7 +269,7 @@ func TestFirewallDBMigration(t *testing.T) {
272
269
// The assertMigrationResults asserts that the migrated entries in the
273
270
// firewall SQLDB match the expected results which should represent the
274
271
// original entries in the BoltDB.
275
- assertMigrationResults := func (t * testing.T , sqlStore * SQLDB ,
272
+ assertMigrationResults := func (t * testing.T , sqlStore * sqlc. Queries ,
276
273
expRes * expectedResult ) {
277
274
278
275
// Assert that the kv store migration results match the expected
@@ -400,7 +397,10 @@ func TestFirewallDBMigration(t *testing.T) {
400
397
require .NoError (t , err )
401
398
402
399
// Assert migration results.
403
- assertMigrationResults (t , sqlStore , entries )
400
+ queries := sqlc .NewForType (
401
+ sqlStore , sqlStore .BackendType ,
402
+ )
403
+ assertMigrationResults (t , queries , entries )
404
404
})
405
405
}
406
406
}
0 commit comments