diff --git a/test/generic_test.dart b/test/generic_test.dart index a060ac56..cd9592a6 100644 --- a/test/generic_test.dart +++ b/test/generic_test.dart @@ -1,4 +1,5 @@ import 'package:angel_framework/angel_framework.dart'; +import 'package:angel_framework/http.dart'; import 'package:angel_mongo/angel_mongo.dart'; import 'package:http/http.dart' as http; import 'package:json_god/json_god.dart' as god; @@ -44,8 +45,8 @@ main() { app.use('/api', greetingService); - var server = await transport.startServer('127.0.0.1', 0); - url = "http://${server.address.host}:${server.port}"; + await transport.startServer('127.0.0.1', 0); + url = transport.uri.toString(); }); tearDown(() async { @@ -58,6 +59,20 @@ main() { greetingService = null; }); + test('query fields mapped to filters', () async { + await greetingService.create({'foo': 'bar'}); + expect( + await greetingService.index({ + 'query': {'foo': 'not bar'} + }), + isEmpty, + ); + expect( + await greetingService.index(), + isNotEmpty, + ); + }); + test('insert items', () async { var response = await client.post("$url/api", body: god.serialize(testGreeting), headers: headers); @@ -133,7 +148,8 @@ main() { var response = await client.get("$url/api?to=world"); print(response.body); - List queried = god.deserialize(response.body, outputType: [].runtimeType); + List queried = + god.deserialize(response.body, outputType: [].runtimeType); expect(queried.length, equals(1)); expect(queried[0].keys.length, equals(2)); expect(queried[0]["id"], equals(world["id"])); @@ -151,7 +167,7 @@ main() { "\$query": { "_id": where.id(new ObjectId.fromHexString(world["id"] as String)) } - }) as List>; + }); print(queried); expect(queried.length, equals(1)); expect(queried[0], equals(world));