Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
synw committed Nov 4, 2019
1 parent cea8cc8 commit d53ee4b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
22 changes: 18 additions & 4 deletions test/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Future<void> setup() async {
'FROM kvstore WHERE key="k_int"') {
final res = <Map<String, dynamic>>[
<String, dynamic>{
"key": "k",
"key": "k_int",
"value": "1",
"type": "int",
"list_type": null,
Expand All @@ -56,7 +56,7 @@ Future<void> setup() async {
'FROM kvstore WHERE key="k_double"') {
final res = <Map<String, dynamic>>[
<String, dynamic>{
"key": "k",
"key": "k_double",
"value": "1.0",
"type": "double",
"list_type": null,
Expand All @@ -70,7 +70,7 @@ Future<void> setup() async {
'FROM kvstore WHERE key="k_list"') {
final res = <Map<String, dynamic>>[
<String, dynamic>{
"key": "k",
"key": "k_list",
"value": "1,2,3",
"type": "List",
"list_type": "int",
Expand All @@ -84,7 +84,7 @@ Future<void> setup() async {
'FROM kvstore WHERE key="k_map"') {
final res = <Map<String, dynamic>>[
<String, dynamic>{
"key": "k",
"key": "k_map",
"value": '{"1":1,"2":2}',
"type": "Map",
"list_type": null,
Expand All @@ -93,6 +93,20 @@ Future<void> setup() async {
}
];
return res;
} else if (methodCall.arguments["sql"] ==
'SELECT key,value,type,list_type,map_key_type,map_value_'
'type FROM kvstore WHERE key="k_bool"') {
final res = <Map<String, dynamic>>[
<String, dynamic>{
"key": "k_bool",
"value": 'true',
"type": "bool",
"list_type": null,
"map_key_type": null,
"map_value_type": null
}
];
return res;
} else if (methodCall.arguments["sql"] == 'SELECT * FROM kvstore') {
final res = <Map<String, dynamic>>[<String, dynamic>{}];
return res;
Expand Down
21 changes: 21 additions & 0 deletions test/kvsql_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:kvsql/src/serializers.dart';
import 'package:pedantic/pedantic.dart';
import 'package:sqlcool/sqlcool.dart';
import 'package:kvsql/kvsql.dart';
Expand Down Expand Up @@ -58,6 +59,19 @@ Future<void> main() async {
return true;
});

test("put bool", () async {
await store.put<bool>("k_bool", true).then((_) async {
final insertedVal =
await store.select<bool>("k_bool").catchError((dynamic e) {
print("EXCEPTION $e / ${e.message}");
throw e;
});
expect(insertedVal is bool, true);
expect(insertedVal, true);
});
return true;
});

test("put list", () async {
await store.put<List<int>>("k_list", [1, 2, 3]).then((_) async {
final insertedVal = await store.select<List<int>>("k_list");
Expand Down Expand Up @@ -148,4 +162,11 @@ Future<void> main() async {
return true;
});
});

group("exceptions", () {
test("encode row", () async {
final encoded = encode<dynamic>(null);
expect(encoded.type, "unknown");
});
});
}

0 comments on commit d53ee4b

Please sign in to comment.