@@ -51,10 +51,10 @@ func TestWhereQueryOnUnencryptedColumn(t *testing.T) {
51
51
t .Fatalf ("Could not insert new example: %v" , err )
52
52
}
53
53
54
- var example Example
54
+ var returnedExample Example
55
55
text := "sydney"
56
56
57
- has , err := engine .Where ("non_encrypted_field = ?" , text ).Get (& example )
57
+ has , err := engine .Where ("non_encrypted_field = ?" , text ).Get (& returnedExample )
58
58
if err != nil {
59
59
t .Fatalf ("Could not retrieve example: %v" , err )
60
60
}
@@ -63,10 +63,10 @@ func TestWhereQueryOnUnencryptedColumn(t *testing.T) {
63
63
t .Errorf ("Expected has to equal true, got: %v" , has )
64
64
}
65
65
66
- assert .Equal (t , newExample .NonEncryptedField , example .NonEncryptedField , "NonEncryptedField does not match" )
67
- assert .Equal (t , newExample .EncryptedIntField , example .EncryptedIntField , "EncryptedIntField does not match" )
68
- assert .Equal (t , newExample .EncryptedTextField , example .EncryptedTextField , "EncryptedTextField does not match" )
69
- assert .Equal (t , newExample .EncryptedJsonbField , example .EncryptedJsonbField , "EncryptedJsonbField does not match" )
66
+ assert .Equal (t , newExample .NonEncryptedField , returnedExample .NonEncryptedField , "NonEncryptedField does not match" )
67
+ assert .Equal (t , newExample .EncryptedIntField , returnedExample .EncryptedIntField , "EncryptedIntField does not match" )
68
+ assert .Equal (t , newExample .EncryptedTextField , returnedExample .EncryptedTextField , "EncryptedTextField does not match" )
69
+ assert .Equal (t , newExample .EncryptedJsonbField , returnedExample .EncryptedJsonbField , "EncryptedJsonbField does not match" )
70
70
}
71
71
72
72
func TestMatchQueryLongString (t * testing.T ) {
@@ -82,6 +82,12 @@ func TestMatchQueryLongString(t *testing.T) {
82
82
}
83
83
84
84
examples := []Example {
85
+ {
86
+ NonEncryptedField : "brisbane" ,
87
+ EncryptedIntField : 23 ,
88
+ EncryptedTextField : "another string that shouldn't be returned" ,
89
+ EncryptedJsonbField : jsonData ,
90
+ },
85
91
{
86
92
NonEncryptedField : "sydney" ,
87
93
EncryptedIntField : 23 ,
@@ -102,9 +108,9 @@ func TestMatchQueryLongString(t *testing.T) {
102
108
t .Errorf ("Error inserting examples: %v" , err )
103
109
}
104
110
105
- assert .Equal (t , int64 (2 ), inserted , "Expected to insert 2 rows" )
111
+ assert .Equal (t , int64 (3 ), inserted , "Expected to insert 2 rows" )
106
112
107
- query , err := goeql .SerializeQuery ("this" , "examples" , "encrypted_text_field" )
113
+ query , err := goeql .MatchQuery ("this" , "examples" , "encrypted_text_field" )
108
114
if err != nil {
109
115
log .Fatalf ("Error marshaling encrypted_text_field query: %v" , err )
110
116
}
@@ -119,7 +125,7 @@ func TestMatchQueryLongString(t *testing.T) {
119
125
t .Errorf ("Expected has to equal true, got: %v" , has )
120
126
}
121
127
122
- assert .Equal (t , returnedExample . EncryptedTextField , EncryptedTextField ("this is a long string" ), "EncryptedTextField should match" )
128
+ assert .Equal (t , EncryptedTextField ("this is a long string" ), returnedExample . EncryptedTextField , "EncryptedTextField should match" )
123
129
}
124
130
125
131
func TestMatchQueryEmail (t * testing.T ) {
@@ -157,7 +163,7 @@ func TestMatchQueryEmail(t *testing.T) {
157
163
158
164
assert .Equal (t , int64 (2 ), inserted , "Expected to insert 2 rows" )
159
165
160
- query , err := goeql .SerializeQuery ("test" , "examples" , "encrypted_text_field" )
166
+ query , err := goeql .MatchQuery ("test" , "examples" , "encrypted_text_field" )
161
167
if err != nil {
162
168
log .Fatalf ("Error marshaling encrypted_text_field query: %v" , err )
163
169
}
@@ -172,7 +178,7 @@ func TestMatchQueryEmail(t *testing.T) {
172
178
t .Errorf ("Expected has to equal true, got: %v" , has )
173
179
}
174
180
175
- assert .Equal (t , returnedExample . EncryptedTextField , EncryptedTextField ("testemail@test.com" ), "EncryptedTextField should match" )
181
+ assert .Equal (t , EncryptedTextField ("testemail@test.com" ), returnedExample . EncryptedTextField , "EncryptedTextField should match" )
176
182
}
177
183
178
184
func TestJsonbQuerySimple (t * testing.T ) {
@@ -218,7 +224,7 @@ func TestJsonbQuerySimple(t *testing.T) {
218
224
},
219
225
}
220
226
221
- query , errTwo := goeql .SerializeQuery (jsonbQuery , "examples" , "encrypted_jsonb_field" )
227
+ query , errTwo := goeql .JsonbQuery (jsonbQuery , "examples" , "encrypted_jsonb_field" )
222
228
if errTwo != nil {
223
229
log .Fatalf ("Error marshaling encrypted_jsonb_field: %v" , errTwo )
224
230
}
@@ -233,7 +239,7 @@ func TestJsonbQuerySimple(t *testing.T) {
233
239
t .Errorf ("Expected has to equal true, got: %v" , has )
234
240
}
235
241
236
- assert .Equal (t , returnedExample . EncryptedJsonbField , EncryptedJsonbField (expectedJson ), "EncryptedJsonb field should match" )
242
+ assert .Equal (t , EncryptedJsonbField (expectedJson ), returnedExample . EncryptedJsonbField , "EncryptedJsonb field should match" )
237
243
}
238
244
239
245
func TestJsonbQueryNested (t * testing.T ) {
@@ -284,7 +290,7 @@ func TestJsonbQueryNested(t *testing.T) {
284
290
},
285
291
}
286
292
287
- query , errTwo := goeql .SerializeQuery (jsonbQuery , "examples" , "encrypted_jsonb_field" )
293
+ query , errTwo := goeql .JsonbQuery (jsonbQuery , "examples" , "encrypted_jsonb_field" )
288
294
if errTwo != nil {
289
295
log .Fatalf ("Error marshaling encrypted_jsonb_field: %v" , errTwo )
290
296
}
@@ -299,7 +305,7 @@ func TestJsonbQueryNested(t *testing.T) {
299
305
t .Errorf ("Expected has to equal true, got: %v" , has )
300
306
}
301
307
302
- assert .Equal (t , returnedExample . EncryptedJsonbField , EncryptedJsonbField (expectedJson ), "EncryptedJsonb field should match" )
308
+ assert .Equal (t , EncryptedJsonbField (expectedJson ), returnedExample . EncryptedJsonbField , "EncryptedJsonb field should match" )
303
309
}
304
310
305
311
func TestOreStringRangeQuery (t * testing.T ) {
@@ -331,7 +337,7 @@ func TestOreStringRangeQuery(t *testing.T) {
331
337
assert .Equal (t , int64 (2 ), inserted , "Expected to insert 2 rows" )
332
338
333
339
// Query
334
- query , errQuery := goeql .SerializeQuery ("tree" , "examples" , "encrypted_text_field" )
340
+ query , errQuery := goeql .OreQuery ("tree" , "examples" , "encrypted_text_field" )
335
341
if errQuery != nil {
336
342
log .Fatalf ("err: %v" , errQuery )
337
343
}
@@ -346,7 +352,7 @@ func TestOreStringRangeQuery(t *testing.T) {
346
352
t .Errorf ("Expected has to equal true, got: %v" , has )
347
353
}
348
354
349
- assert .Equal (t , returnedExample .EncryptedTextField , expected , "EncryptedText field should match" )
355
+ assert .Equal (t , expected , returnedExample .EncryptedTextField , "EncryptedText field should match" )
350
356
}
351
357
352
358
func TestOreIntRangeQuery (t * testing.T ) {
@@ -378,7 +384,7 @@ func TestOreIntRangeQuery(t *testing.T) {
378
384
assert .Equal (t , int64 (2 ), inserted , "Expected to insert 2 rows" )
379
385
380
386
// Query
381
- query , errQuery := goeql .SerializeQuery (32 , "examples" , "encrypted_int_field" )
387
+ query , errQuery := goeql .OreQuery (32 , "examples" , "encrypted_int_field" )
382
388
if errQuery != nil {
383
389
log .Fatalf ("err: %v" , errQuery )
384
390
}
@@ -393,7 +399,7 @@ func TestOreIntRangeQuery(t *testing.T) {
393
399
t .Errorf ("Expected has to equal true, got: %v" , has )
394
400
}
395
401
396
- assert .Equal (t , returnedExample .EncryptedIntField , expected , "EncryptedInt field should match" )
402
+ assert .Equal (t , expected , returnedExample .EncryptedIntField , "EncryptedInt field should match" )
397
403
}
398
404
399
405
func TestOreBoolRangeQuery (t * testing.T ) {
@@ -434,7 +440,7 @@ func TestOreBoolRangeQuery(t *testing.T) {
434
440
assert .Equal (t , int64 (3 ), inserted , "Expected to insert 3 rows" )
435
441
436
442
// Query
437
- query , errQuery := goeql .SerializeQuery (false , "examples" , "encrypted_bool_field" )
443
+ query , errQuery := goeql .OreQuery (false , "examples" , "encrypted_bool_field" )
438
444
if errQuery != nil {
439
445
log .Fatalf ("err: %v" , errQuery )
440
446
}
@@ -449,7 +455,7 @@ func TestOreBoolRangeQuery(t *testing.T) {
449
455
t .Errorf ("Expected has to equal true, got: %v" , has )
450
456
}
451
457
452
- assert .Equal (t , returnedExample .EncryptedBoolField , expected , "EncryptedBool field should match" )
458
+ assert .Equal (t , expected , returnedExample .EncryptedBoolField , "EncryptedBool field should match" )
453
459
}
454
460
455
461
func TestUniqueStringQuery (t * testing.T ) {
@@ -490,7 +496,7 @@ func TestUniqueStringQuery(t *testing.T) {
490
496
assert .Equal (t , int64 (3 ), inserted , "Expected to insert 3 rows" )
491
497
492
498
// Query
493
- query , errQuery := goeql .SerializeQuery ("testing two" , "examples" , "encrypted_text_field" )
499
+ query , errQuery := goeql .UniqueQuery ("testing two" , "examples" , "encrypted_text_field" )
494
500
if errQuery != nil {
495
501
log .Fatalf ("err: %v" , errQuery )
496
502
}
@@ -505,5 +511,5 @@ func TestUniqueStringQuery(t *testing.T) {
505
511
t .Errorf ("Expected has to equal true, got: %v" , has )
506
512
}
507
513
508
- assert .Equal (t , returnedExample .EncryptedTextField , expected , "EncryptedText field should match" )
514
+ assert .Equal (t , expected , returnedExample .EncryptedTextField , "EncryptedText field should match" )
509
515
}
0 commit comments