@@ -28,7 +28,7 @@ func TestSimpleQuery(t *testing.T) {
28
28
29
29
rawQuery := []byte (`{"selector":{"owner":{"$eq":"jerry"}},"limit": 10,"skip": 0}` )
30
30
31
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
31
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
32
32
33
33
//Make sure the query did not throw an exception
34
34
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -49,7 +49,7 @@ func TestQueryWithOperator(t *testing.T) {
49
49
50
50
rawQuery := []byte (`{"selector":{"$or":[{"owner":{"$eq":"jerry"}},{"owner": {"$eq": "frank"}}]},"limit": 10,"skip": 0}` )
51
51
52
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
52
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
53
53
54
54
//Make sure the query did not throw an exception
55
55
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -72,7 +72,7 @@ func TestQueryWithImplicitOperatorAndExplicitOperator(t *testing.T) {
72
72
73
73
rawQuery := []byte (`{"selector":{"color":"green","$or":[{"owner":"fred"},{"owner":"mary"}]}}` )
74
74
75
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
75
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
76
76
77
77
//Make sure the query did not throw an exception
78
78
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -97,7 +97,7 @@ func TestQueryWithFields(t *testing.T) {
97
97
98
98
rawQuery := []byte (`{"selector":{"owner": {"$eq": "tom"}},"fields": ["owner", "asset_name", "color", "size"], "limit": 10, "skip": 0}` )
99
99
100
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
100
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
101
101
102
102
//Make sure the query did not throw an exception
103
103
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -124,7 +124,7 @@ func TestQueryWithSortFields(t *testing.T) {
124
124
125
125
rawQuery := []byte (`{"selector":{"owner": {"$eq": "tom"}},"fields": ["owner", "asset_name", "color", "size"], "sort": ["size", "color"], "limit": 10, "skip": 0}` )
126
126
127
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
127
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
128
128
129
129
//Make sure the query did not throw an exception
130
130
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -151,7 +151,7 @@ func TestQueryWithSortObjects(t *testing.T) {
151
151
152
152
rawQuery := []byte (`{"selector":{"owner": {"$eq": "tom"}},"fields": ["owner", "asset_name", "color", "size"], "sort": [{"size": "desc"}, {"color": "desc"}], "limit": 10, "skip": 0}` )
153
153
154
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
154
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
155
155
156
156
//Make sure the query did not throw an exception
157
157
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -191,13 +191,13 @@ func TestQueryLeadingOperator(t *testing.T) {
191
191
}
192
192
}` )
193
193
194
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
194
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
195
195
196
196
//Make sure the query did not throw an exception
197
197
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
198
198
199
199
//$and operator should be unchanged
200
- testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $and\" " ), 2 )
200
+ testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $and\" " ), 1 )
201
201
202
202
//$gte operator should be unchanged
203
203
testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $gte\" " ), 1 )
@@ -221,13 +221,13 @@ func TestQueryLeadingAndEmbeddedOperator(t *testing.T) {
221
221
]
222
222
}}` )
223
223
224
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
224
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
225
225
226
226
//Make sure the query did not throw an exception
227
227
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
228
228
229
229
//$and operator should be unchanged
230
- testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $and\" " ), 2 )
230
+ testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $and\" " ), 1 )
231
231
232
232
//$gte operator should be unchanged
233
233
testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $gte\" " ), 1 )
@@ -266,13 +266,13 @@ func TestQueryEmbeddedOperatorAndArrayOfObjects(t *testing.T) {
266
266
}
267
267
}` )
268
268
269
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
269
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
270
270
271
271
//Make sure the query did not throw an exception
272
272
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
273
273
274
274
//$and operator should be unchanged
275
- testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $and\" " ), 2 )
275
+ testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $and\" " ), 1 )
276
276
277
277
//$gte operator should be unchanged
278
278
testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" $gte\" " ), 1 )
@@ -297,7 +297,7 @@ func TestQueryEmbeddedOperatorAndArrayOfValues(t *testing.T) {
297
297
}
298
298
}` )
299
299
300
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
300
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
301
301
302
302
//Make sure the query did not throw an exception
303
303
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -322,27 +322,12 @@ func TestQueryEmbeddedOperatorAndArrayOfValues(t *testing.T) {
322
322
323
323
}
324
324
325
- //TestQueryNoSelector with no selector specified
326
- func TestQueryNoSelector (t * testing.T ) {
327
-
328
- rawQuery := []byte (`{"fields": ["owner", "asset_name", "color", "size"]}` )
329
-
330
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
331
-
332
- //Make sure the query did not throw an exception
333
- testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
334
-
335
- //check to make sure the default selector is added
336
- testutil .AssertEquals (t , strings .Count (wrappedQuery , "\" selector\" :{\" chaincodeid\" :\" ns1\" }" ), 1 )
337
-
338
- }
339
-
340
325
//TestQueryWithUseDesignDoc tests query with index design doc specified
341
326
func TestQueryWithUseDesignDoc (t * testing.T ) {
342
327
343
328
rawQuery := []byte (`{"selector":{"owner":{"$eq":"jerry"}},"use_index":"_design/testDoc","limit": 10,"skip": 0}` )
344
329
345
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
330
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
346
331
347
332
//Make sure the query did not throw an exception
348
333
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -357,7 +342,7 @@ func TestQueryWithUseDesignDocAndIndexName(t *testing.T) {
357
342
358
343
rawQuery := []byte (`{"selector":{"owner":{"$eq":"jerry"}},"use_index":["_design/testDoc","testIndexName"],"limit": 10,"skip": 0}` )
359
344
360
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
345
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
361
346
362
347
//Make sure the query did not throw an exception
363
348
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
@@ -372,7 +357,7 @@ func TestQueryWithLargeInteger(t *testing.T) {
372
357
373
358
rawQuery := []byte (`{"selector":{"$and":[{"size":{"$eq": 1000007}}]}}` )
374
359
375
- wrappedQuery , err := ApplyQueryWrapper ("ns1" , string (rawQuery ), 10000 , 0 )
360
+ wrappedQuery , err := ApplyQueryWrapper (string (rawQuery ), 10000 , 0 )
376
361
377
362
//Make sure the query did not throw an exception
378
363
testutil .AssertNoError (t , err , "Unexpected error thrown when for query JSON" )
0 commit comments