From d53ee4bf5f87d04d6ade82e762a75341ca4b2cf5 Mon Sep 17 00:00:00 2001 From: synw Date: Mon, 4 Nov 2019 06:38:29 +0100 Subject: [PATCH] Update tests --- test/base.dart | 22 ++++++++++++++++++---- test/kvsql_test.dart | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/test/base.dart b/test/base.dart index 9926aa0..4ed3e03 100644 --- a/test/base.dart +++ b/test/base.dart @@ -42,7 +42,7 @@ Future setup() async { 'FROM kvstore WHERE key="k_int"') { final res = >[ { - "key": "k", + "key": "k_int", "value": "1", "type": "int", "list_type": null, @@ -56,7 +56,7 @@ Future setup() async { 'FROM kvstore WHERE key="k_double"') { final res = >[ { - "key": "k", + "key": "k_double", "value": "1.0", "type": "double", "list_type": null, @@ -70,7 +70,7 @@ Future setup() async { 'FROM kvstore WHERE key="k_list"') { final res = >[ { - "key": "k", + "key": "k_list", "value": "1,2,3", "type": "List", "list_type": "int", @@ -84,7 +84,7 @@ Future setup() async { 'FROM kvstore WHERE key="k_map"') { final res = >[ { - "key": "k", + "key": "k_map", "value": '{"1":1,"2":2}', "type": "Map", "list_type": null, @@ -93,6 +93,20 @@ Future 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 = >[ + { + "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 = >[{}]; return res; diff --git a/test/kvsql_test.dart b/test/kvsql_test.dart index 1c195b0..8d4e0c0 100644 --- a/test/kvsql_test.dart +++ b/test/kvsql_test.dart @@ -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'; @@ -58,6 +59,19 @@ Future main() async { return true; }); + test("put bool", () async { + await store.put("k_bool", true).then((_) async { + final insertedVal = + await store.select("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>("k_list", [1, 2, 3]).then((_) async { final insertedVal = await store.select>("k_list"); @@ -148,4 +162,11 @@ Future main() async { return true; }); }); + + group("exceptions", () { + test("encode row", () async { + final encoded = encode(null); + expect(encoded.type, "unknown"); + }); + }); }