@@ -51,10 +51,10 @@ func TestWhereQueryOnUnencryptedColumn(t *testing.T) {
5151 t .Fatalf ("Could not insert new example: %v" , err )
5252 }
5353
54- var example Example
54+ var returnedExample Example
5555 text := "sydney"
5656
57- has , err := engine .Where ("non_encrypted_field = ?" , text ).Get (& example )
57+ has , err := engine .Where ("non_encrypted_field = ?" , text ).Get (& returnedExample )
5858 if err != nil {
5959 t .Fatalf ("Could not retrieve example: %v" , err )
6060 }
@@ -63,10 +63,10 @@ func TestWhereQueryOnUnencryptedColumn(t *testing.T) {
6363 t .Errorf ("Expected has to equal true, got: %v" , has )
6464 }
6565
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" )
7070}
7171
7272func TestMatchQueryLongString (t * testing.T ) {
@@ -82,6 +82,12 @@ func TestMatchQueryLongString(t *testing.T) {
8282 }
8383
8484 examples := []Example {
85+ {
86+ NonEncryptedField : "brisbane" ,
87+ EncryptedIntField : 23 ,
88+ EncryptedTextField : "another string that shouldn't be returned" ,
89+ EncryptedJsonbField : jsonData ,
90+ },
8591 {
8692 NonEncryptedField : "sydney" ,
8793 EncryptedIntField : 23 ,
@@ -102,9 +108,9 @@ func TestMatchQueryLongString(t *testing.T) {
102108 t .Errorf ("Error inserting examples: %v" , err )
103109 }
104110
105- assert .Equal (t , int64 (2 ), inserted , "Expected to insert 2 rows" )
111+ assert .Equal (t , int64 (3 ), inserted , "Expected to insert 2 rows" )
106112
107- query , err := goeql .SerializeQuery ("this" , "examples" , "encrypted_text_field" )
113+ query , err := goeql .MatchQuery ("this" , "examples" , "encrypted_text_field" )
108114 if err != nil {
109115 log .Fatalf ("Error marshaling encrypted_text_field query: %v" , err )
110116 }
@@ -119,7 +125,7 @@ func TestMatchQueryLongString(t *testing.T) {
119125 t .Errorf ("Expected has to equal true, got: %v" , has )
120126 }
121127
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" )
123129}
124130
125131func TestMatchQueryEmail (t * testing.T ) {
@@ -157,7 +163,7 @@ func TestMatchQueryEmail(t *testing.T) {
157163
158164 assert .Equal (t , int64 (2 ), inserted , "Expected to insert 2 rows" )
159165
160- query , err := goeql .SerializeQuery ("test" , "examples" , "encrypted_text_field" )
166+ query , err := goeql .MatchQuery ("test" , "examples" , "encrypted_text_field" )
161167 if err != nil {
162168 log .Fatalf ("Error marshaling encrypted_text_field query: %v" , err )
163169 }
@@ -172,7 +178,7 @@ func TestMatchQueryEmail(t *testing.T) {
172178 t .Errorf ("Expected has to equal true, got: %v" , has )
173179 }
174180
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" )
176182}
177183
178184func TestJsonbQuerySimple (t * testing.T ) {
@@ -218,7 +224,7 @@ func TestJsonbQuerySimple(t *testing.T) {
218224 },
219225 }
220226
221- query , errTwo := goeql .SerializeQuery (jsonbQuery , "examples" , "encrypted_jsonb_field" )
227+ query , errTwo := goeql .JsonbQuery (jsonbQuery , "examples" , "encrypted_jsonb_field" )
222228 if errTwo != nil {
223229 log .Fatalf ("Error marshaling encrypted_jsonb_field: %v" , errTwo )
224230 }
@@ -233,7 +239,7 @@ func TestJsonbQuerySimple(t *testing.T) {
233239 t .Errorf ("Expected has to equal true, got: %v" , has )
234240 }
235241
236- assert .Equal (t , returnedExample . EncryptedJsonbField , EncryptedJsonbField (expectedJson ), "EncryptedJsonb field should match" )
242+ assert .Equal (t , EncryptedJsonbField (expectedJson ), returnedExample . EncryptedJsonbField , "EncryptedJsonb field should match" )
237243}
238244
239245func TestJsonbQueryNested (t * testing.T ) {
@@ -284,7 +290,7 @@ func TestJsonbQueryNested(t *testing.T) {
284290 },
285291 }
286292
287- query , errTwo := goeql .SerializeQuery (jsonbQuery , "examples" , "encrypted_jsonb_field" )
293+ query , errTwo := goeql .JsonbQuery (jsonbQuery , "examples" , "encrypted_jsonb_field" )
288294 if errTwo != nil {
289295 log .Fatalf ("Error marshaling encrypted_jsonb_field: %v" , errTwo )
290296 }
@@ -299,7 +305,7 @@ func TestJsonbQueryNested(t *testing.T) {
299305 t .Errorf ("Expected has to equal true, got: %v" , has )
300306 }
301307
302- assert .Equal (t , returnedExample . EncryptedJsonbField , EncryptedJsonbField (expectedJson ), "EncryptedJsonb field should match" )
308+ assert .Equal (t , EncryptedJsonbField (expectedJson ), returnedExample . EncryptedJsonbField , "EncryptedJsonb field should match" )
303309}
304310
305311func TestOreStringRangeQuery (t * testing.T ) {
@@ -331,7 +337,7 @@ func TestOreStringRangeQuery(t *testing.T) {
331337 assert .Equal (t , int64 (2 ), inserted , "Expected to insert 2 rows" )
332338
333339 // Query
334- query , errQuery := goeql .SerializeQuery ("tree" , "examples" , "encrypted_text_field" )
340+ query , errQuery := goeql .OreQuery ("tree" , "examples" , "encrypted_text_field" )
335341 if errQuery != nil {
336342 log .Fatalf ("err: %v" , errQuery )
337343 }
@@ -346,7 +352,7 @@ func TestOreStringRangeQuery(t *testing.T) {
346352 t .Errorf ("Expected has to equal true, got: %v" , has )
347353 }
348354
349- assert .Equal (t , returnedExample .EncryptedTextField , expected , "EncryptedText field should match" )
355+ assert .Equal (t , expected , returnedExample .EncryptedTextField , "EncryptedText field should match" )
350356}
351357
352358func TestOreIntRangeQuery (t * testing.T ) {
@@ -378,7 +384,7 @@ func TestOreIntRangeQuery(t *testing.T) {
378384 assert .Equal (t , int64 (2 ), inserted , "Expected to insert 2 rows" )
379385
380386 // Query
381- query , errQuery := goeql .SerializeQuery (32 , "examples" , "encrypted_int_field" )
387+ query , errQuery := goeql .OreQuery (32 , "examples" , "encrypted_int_field" )
382388 if errQuery != nil {
383389 log .Fatalf ("err: %v" , errQuery )
384390 }
@@ -393,7 +399,7 @@ func TestOreIntRangeQuery(t *testing.T) {
393399 t .Errorf ("Expected has to equal true, got: %v" , has )
394400 }
395401
396- assert .Equal (t , returnedExample .EncryptedIntField , expected , "EncryptedInt field should match" )
402+ assert .Equal (t , expected , returnedExample .EncryptedIntField , "EncryptedInt field should match" )
397403}
398404
399405func TestOreBoolRangeQuery (t * testing.T ) {
@@ -434,7 +440,7 @@ func TestOreBoolRangeQuery(t *testing.T) {
434440 assert .Equal (t , int64 (3 ), inserted , "Expected to insert 3 rows" )
435441
436442 // Query
437- query , errQuery := goeql .SerializeQuery (false , "examples" , "encrypted_bool_field" )
443+ query , errQuery := goeql .OreQuery (false , "examples" , "encrypted_bool_field" )
438444 if errQuery != nil {
439445 log .Fatalf ("err: %v" , errQuery )
440446 }
@@ -449,7 +455,7 @@ func TestOreBoolRangeQuery(t *testing.T) {
449455 t .Errorf ("Expected has to equal true, got: %v" , has )
450456 }
451457
452- assert .Equal (t , returnedExample .EncryptedBoolField , expected , "EncryptedBool field should match" )
458+ assert .Equal (t , expected , returnedExample .EncryptedBoolField , "EncryptedBool field should match" )
453459}
454460
455461func TestUniqueStringQuery (t * testing.T ) {
@@ -490,7 +496,7 @@ func TestUniqueStringQuery(t *testing.T) {
490496 assert .Equal (t , int64 (3 ), inserted , "Expected to insert 3 rows" )
491497
492498 // Query
493- query , errQuery := goeql .SerializeQuery ("testing two" , "examples" , "encrypted_text_field" )
499+ query , errQuery := goeql .UniqueQuery ("testing two" , "examples" , "encrypted_text_field" )
494500 if errQuery != nil {
495501 log .Fatalf ("err: %v" , errQuery )
496502 }
@@ -505,5 +511,5 @@ func TestUniqueStringQuery(t *testing.T) {
505511 t .Errorf ("Expected has to equal true, got: %v" , has )
506512 }
507513
508- assert .Equal (t , returnedExample .EncryptedTextField , expected , "EncryptedText field should match" )
514+ assert .Equal (t , expected , returnedExample .EncryptedTextField , "EncryptedText field should match" )
509515}
0 commit comments