remove nonexistent
This commit is contained in:
parent
7137dcad5b
commit
8cff7a3f2c
3 changed files with 14 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,3 +11,4 @@ pubspec.lock
|
||||||
# If you don't generate documentation locally you can remove this line.
|
# If you don't generate documentation locally you can remove this line.
|
||||||
doc/api/
|
doc/api/
|
||||||
.dart_tool
|
.dart_tool
|
||||||
|
dump.rdb
|
||||||
|
|
|
@ -64,6 +64,11 @@ class RedisService extends Service<String, Map<String, dynamic>> {
|
||||||
await client.writeArrayOfBulk(['DEL', _applyPrefix(id)]);
|
await client.writeArrayOfBulk(['DEL', _applyPrefix(id)]);
|
||||||
var result = await client.writeArrayOfBulk(['EXEC']);
|
var result = await client.writeArrayOfBulk(['EXEC']);
|
||||||
var str = result.payload[0] as RespBulkString;
|
var str = result.payload[0] as RespBulkString;
|
||||||
|
|
||||||
|
if (str.payload == null)
|
||||||
|
throw new AngelHttpException.notFound(
|
||||||
|
message: 'No record found for ID $id');
|
||||||
|
else
|
||||||
return json.decode(str.payload);
|
return json.decode(str.payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:angel_http_exception/angel_http_exception.dart';
|
||||||
import 'package:angel_redis/angel_redis.dart';
|
import 'package:angel_redis/angel_redis.dart';
|
||||||
import 'package:resp_client/resp_client.dart';
|
import 'package:resp_client/resp_client.dart';
|
||||||
import 'package:resp_client/resp_commands.dart';
|
import 'package:resp_client/resp_commands.dart';
|
||||||
|
@ -47,5 +48,11 @@ main() async {
|
||||||
var id = 'gelatin${new DateTime.now().millisecondsSinceEpoch}';
|
var id = 'gelatin${new DateTime.now().millisecondsSinceEpoch}';
|
||||||
var input = await service.create({'id': id, 'bar': 'baz'});
|
var input = await service.create({'id': id, 'bar': 'baz'});
|
||||||
expect(await service.remove(id), input);
|
expect(await service.remove(id), input);
|
||||||
|
expect(await service.respCommands.exists([id]), 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('remove nonexistent', () async {
|
||||||
|
expect(() => service.remove('definitely_does_not_exist'),
|
||||||
|
throwsA(const TypeMatcher<AngelHttpException>()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue