@@ -11,7 +11,7 @@ import (
11
11
"testing"
12
12
"time"
13
13
14
- . "github.com/onsi/gomega"
14
+ ga "github.com/onsi/gomega"
15
15
bolt "go.etcd.io/bbolt"
16
16
17
17
"github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
@@ -20,13 +20,13 @@ import (
20
20
21
21
func TestInitializeBuckets (t * testing.T ) {
22
22
t .Run ("normal test" , func (t * testing.T ) {
23
- g := NewWithT (t )
23
+ g := ga . NewWithT (t )
24
24
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
25
- g .Expect (err ).ToNot (HaveOccurred ())
25
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
26
26
defer db .Close ()
27
27
28
28
err = initializeBuckets (db )
29
- g .Expect (err ).ToNot (HaveOccurred ())
29
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
30
30
31
31
actualBuckets := [][]byte {}
32
32
err = db .View (func (t * bolt.Tx ) error {
@@ -35,42 +35,42 @@ func TestInitializeBuckets(t *testing.T) {
35
35
return nil
36
36
})
37
37
})
38
- g .Expect (err ).ToNot (HaveOccurred ())
38
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
39
39
40
- g .Expect (actualBuckets ).To (Equal (allBuckets ))
40
+ g .Expect (actualBuckets ).To (ga . Equal (allBuckets ))
41
41
})
42
42
}
43
43
44
44
func TestCleanupExpiredData (t * testing.T ) {
45
45
t .Run ("negative expired seconds" , func (t * testing.T ) {
46
- g := NewWithT (t )
46
+ g := ga . NewWithT (t )
47
47
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
48
- g .Expect (err ).ToNot (HaveOccurred ())
48
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
49
49
defer db .Close ()
50
50
51
51
err = cleanupExpiredData (- 1 * time .Second , db )
52
- g .Expect (err ).ToNot (HaveOccurred ())
52
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
53
53
})
54
54
55
55
t .Run ("nil global bucket" , func (t * testing.T ) {
56
- g := NewWithT (t )
56
+ g := ga . NewWithT (t )
57
57
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
58
- g .Expect (err ).ToNot (HaveOccurred ())
58
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
59
59
defer db .Close ()
60
60
61
61
err = cleanupExpiredData (time .Second , db )
62
- g .Expect (err ).ToNot (HaveOccurred ())
62
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
63
63
})
64
64
65
65
t .Run ("normal test" , func (t * testing.T ) {
66
- g := NewWithT (t )
66
+ g := ga . NewWithT (t )
67
67
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
68
- g .Expect (err ).ToNot (HaveOccurred ())
68
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
69
69
defer db .Close ()
70
70
71
71
// Initialize data
72
72
err = initializeBuckets (db )
73
- g .Expect (err ).ToNot (HaveOccurred ())
73
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
74
74
75
75
err = db .Update (func (t * bolt.Tx ) error {
76
76
doneTime := time .Now ().Add (- 10 * time .Minute )
@@ -95,10 +95,10 @@ func TestCleanupExpiredData(t *testing.T) {
95
95
96
96
return nil
97
97
})
98
- g .Expect (err ).ToNot (HaveOccurred ())
98
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
99
99
100
100
err = cleanupExpiredData (time .Minute , db )
101
- g .Expect (err ).ToNot (HaveOccurred ())
101
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
102
102
103
103
actualGids := []string {}
104
104
err = db .View (func (t * bolt.Tx ) error {
@@ -108,29 +108,29 @@ func TestCleanupExpiredData(t *testing.T) {
108
108
}
109
109
return nil
110
110
})
111
- g .Expect (err ).ToNot (HaveOccurred ())
112
- g .Expect (actualGids ).To (Equal ([]string {"gid0" }))
111
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
112
+ g .Expect (actualGids ).To (ga . Equal ([]string {"gid0" }))
113
113
})
114
114
}
115
115
116
116
func TestCleanupGlobalWithGids (t * testing.T ) {
117
117
t .Run ("nil bucket" , func (t * testing.T ) {
118
- g := NewWithT (t )
118
+ g := ga . NewWithT (t )
119
119
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
120
- g .Expect (err ).ToNot (HaveOccurred ())
120
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
121
121
defer db .Close ()
122
122
123
123
err = db .Update (func (t * bolt.Tx ) error {
124
124
cleanupGlobalWithGids (t , nil )
125
125
return nil
126
126
})
127
- g .Expect (err ).ToNot (HaveOccurred ())
127
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
128
128
})
129
129
130
130
t .Run ("normal test" , func (t * testing.T ) {
131
- g := NewWithT (t )
131
+ g := ga . NewWithT (t )
132
132
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
133
- g .Expect (err ).ToNot (HaveOccurred ())
133
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
134
134
defer db .Close ()
135
135
136
136
// Initialize data
@@ -151,7 +151,7 @@ func TestCleanupGlobalWithGids(t *testing.T) {
151
151
152
152
return nil
153
153
})
154
- g .Expect (err ).ToNot (HaveOccurred ())
154
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
155
155
156
156
err = db .Update (func (t * bolt.Tx ) error {
157
157
cleanupGlobalWithGids (t , map [string ]struct {}{
@@ -160,7 +160,7 @@ func TestCleanupGlobalWithGids(t *testing.T) {
160
160
})
161
161
return nil
162
162
})
163
- g .Expect (err ).ToNot (HaveOccurred ())
163
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
164
164
165
165
actualGids := []string {}
166
166
err = db .View (func (t * bolt.Tx ) error {
@@ -170,29 +170,29 @@ func TestCleanupGlobalWithGids(t *testing.T) {
170
170
}
171
171
return nil
172
172
})
173
- g .Expect (err ).ToNot (HaveOccurred ())
174
- g .Expect (actualGids ).To (Equal ([]string {"k3" }))
173
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
174
+ g .Expect (actualGids ).To (ga . Equal ([]string {"k3" }))
175
175
})
176
176
}
177
177
178
178
func TestCleanupBranchWithGids (t * testing.T ) {
179
179
t .Run ("nil bucket" , func (t * testing.T ) {
180
- g := NewWithT (t )
180
+ g := ga . NewWithT (t )
181
181
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
182
- g .Expect (err ).ToNot (HaveOccurred ())
182
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
183
183
defer db .Close ()
184
184
185
185
err = db .Update (func (t * bolt.Tx ) error {
186
186
cleanupBranchWithGids (t , nil )
187
187
return nil
188
188
})
189
- g .Expect (err ).ToNot (HaveOccurred ())
189
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
190
190
})
191
191
192
192
t .Run ("normal test" , func (t * testing.T ) {
193
- g := NewWithT (t )
193
+ g := ga . NewWithT (t )
194
194
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
195
- g .Expect (err ).ToNot (HaveOccurred ())
195
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
196
196
defer db .Close ()
197
197
198
198
// Initialize data
@@ -232,7 +232,7 @@ func TestCleanupBranchWithGids(t *testing.T) {
232
232
233
233
return nil
234
234
})
235
- g .Expect (err ).ToNot (HaveOccurred ())
235
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
236
236
237
237
err = db .Update (func (t * bolt.Tx ) error {
238
238
cleanupBranchWithGids (t , map [string ]struct {}{
@@ -241,7 +241,7 @@ func TestCleanupBranchWithGids(t *testing.T) {
241
241
})
242
242
return nil
243
243
})
244
- g .Expect (err ).ToNot (HaveOccurred ())
244
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
245
245
246
246
actualKeys := []string {}
247
247
err = db .View (func (t * bolt.Tx ) error {
@@ -251,29 +251,29 @@ func TestCleanupBranchWithGids(t *testing.T) {
251
251
}
252
252
return nil
253
253
})
254
- g .Expect (err ).ToNot (HaveOccurred ())
255
- g .Expect (actualKeys ).To (Equal ([]string {"a" , "gid201" , "z" }))
254
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
255
+ g .Expect (actualKeys ).To (ga . Equal ([]string {"a" , "gid201" , "z" }))
256
256
})
257
257
}
258
258
259
259
func TestCleanupIndexWithGids (t * testing.T ) {
260
260
t .Run ("nil bucket" , func (t * testing.T ) {
261
- g := NewWithT (t )
261
+ g := ga . NewWithT (t )
262
262
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
263
- g .Expect (err ).ToNot (HaveOccurred ())
263
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
264
264
defer db .Close ()
265
265
266
266
err = db .Update (func (t * bolt.Tx ) error {
267
267
cleanupIndexWithGids (t , nil )
268
268
return nil
269
269
})
270
- g .Expect (err ).ToNot (HaveOccurred ())
270
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
271
271
})
272
272
273
273
t .Run ("normal test" , func (t * testing.T ) {
274
- g := NewWithT (t )
274
+ g := ga . NewWithT (t )
275
275
db , err := bolt .Open (path .Join (t .TempDir (), "./test.bolt" ), 0666 , & bolt.Options {Timeout : 1 * time .Second })
276
- g .Expect (err ).ToNot (HaveOccurred ())
276
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
277
277
defer db .Close ()
278
278
279
279
// Initialize data
@@ -313,7 +313,7 @@ func TestCleanupIndexWithGids(t *testing.T) {
313
313
314
314
return nil
315
315
})
316
- g .Expect (err ).ToNot (HaveOccurred ())
316
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
317
317
318
318
err = db .Update (func (t * bolt.Tx ) error {
319
319
cleanupIndexWithGids (t , map [string ]struct {}{
@@ -322,7 +322,7 @@ func TestCleanupIndexWithGids(t *testing.T) {
322
322
})
323
323
return nil
324
324
})
325
- g .Expect (err ).ToNot (HaveOccurred ())
325
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
326
326
327
327
actualKeys := []string {}
328
328
err = db .View (func (t * bolt.Tx ) error {
@@ -332,7 +332,7 @@ func TestCleanupIndexWithGids(t *testing.T) {
332
332
}
333
333
return nil
334
334
})
335
- g .Expect (err ).ToNot (HaveOccurred ())
336
- g .Expect (actualKeys ).To (Equal ([]string {"3-gid2" , "a" , "z" }))
335
+ g .Expect (err ).ToNot (ga . HaveOccurred ())
336
+ g .Expect (actualKeys ).To (ga . Equal ([]string {"3-gid2" , "a" , "z" }))
337
337
})
338
338
}
0 commit comments