2018-10-21 12:29:42 +00:00
|
|
|
import 'package:angel_redis/angel_redis.dart';
|
|
|
|
import 'package:resp_client/resp_client.dart';
|
|
|
|
import 'package:resp_client/resp_commands.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
main() async {
|
|
|
|
RespServerConnection connection;
|
|
|
|
RedisService service;
|
|
|
|
|
|
|
|
setUp(() async {
|
|
|
|
connection = await connectSocket('localhost');
|
|
|
|
service = new RedisService(new RespCommands(new RespClient(connection)),
|
|
|
|
prefix: 'angel_redis_test');
|
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() => connection.close());
|
|
|
|
|
|
|
|
test('create with id', () async {
|
|
|
|
var input = {'id': 'foo', 'bar': 'baz'};
|
|
|
|
var output = await service.create(input);
|
|
|
|
expect(input, output);
|
|
|
|
});
|
2018-10-21 16:29:04 +00:00
|
|
|
|
2018-10-21 16:26:53 +00:00
|
|
|
test('create without id', () async {
|
|
|
|
var input = {'bar': 'baz'};
|
|
|
|
var output = await service.create(input);
|
|
|
|
print(output);
|
|
|
|
expect(output.keys, contains('id'));
|
|
|
|
expect(output, containsPair('bar', 'baz'));
|
|
|
|
});
|
2018-10-21 16:29:04 +00:00
|
|
|
|
|
|
|
test('read', () async {
|
|
|
|
var id = 'poobah${new DateTime.now().millisecondsSinceEpoch}';
|
|
|
|
var input = await service.create({'id': id, 'bar': 'baz'});
|
|
|
|
expect(await service.read(id), input);
|
|
|
|
});
|
2018-10-21 16:31:30 +00:00
|
|
|
|
|
|
|
test('update', () async {
|
|
|
|
var id = 'hoopla${new DateTime.now().millisecondsSinceEpoch}';
|
|
|
|
await service.create({'id': id, 'bar': 'baz'});
|
|
|
|
var output = await service.update(id, {'bar': 'quux'});
|
|
|
|
expect(output, {'id': id, 'bar': 'quux'});
|
|
|
|
expect(await service.read(id), output);
|
|
|
|
});
|
2018-10-21 12:29:42 +00:00
|
|
|
}
|