Extend hope_kv_list validation API with:
[hope.git] / test / hope_kv_list_SUITE.erl
index 511fc32..3ae5290 100644 (file)
@@ -1,5 +1,7 @@
 -module(hope_kv_list_SUITE).
 
+-include_lib("hope_kv_list.hrl").
+
 %% Callbacks
 -export(
     [ all/0
@@ -40,11 +42,39 @@ t_validate_unique_presence(_Cfg) ->
     DictUnsup   = [{a, 1}, {b, 2}, {c, 3}, {d, 4}],
     DictDups    = [{a, 1}, {b, 2}, {c, 3}, {a, 4}],
     DictMissing = [{a, 1}, {b, 2}],
+
     {ok, ok} =
         hope_kv_list:validate_unique_presence(DictOk, KeysRequired),
+    #hope_kv_list_presence_violations
+    { keys_missing     = []
+    , keys_duplicated  = []
+    , keys_unsupported = []
+    } =
+        hope_kv_list:find_unique_presence_violations(DictOk, KeysRequired),
+
     {error, [{keys_unsupported, [d]}]} =
         hope_kv_list:validate_unique_presence(DictUnsup, KeysRequired),
+    #hope_kv_list_presence_violations
+    { keys_missing     = []
+    , keys_duplicated  = []
+    , keys_unsupported = [d]
+    } =
+        hope_kv_list:find_unique_presence_violations(DictUnsup, KeysRequired),
+
     {error, [{keys_duplicated, [a]}]} =
         hope_kv_list:validate_unique_presence(DictDups, KeysRequired),
+    #hope_kv_list_presence_violations
+    { keys_missing     = []
+    , keys_duplicated  = [a]
+    , keys_unsupported = []
+    } =
+        hope_kv_list:find_unique_presence_violations(DictDups, KeysRequired),
+
     {error, [{keys_missing, [c]}]} =
-        hope_kv_list:validate_unique_presence(DictMissing, KeysRequired).
+        hope_kv_list:validate_unique_presence(DictMissing, KeysRequired),
+    #hope_kv_list_presence_violations
+    { keys_missing     = [c]
+    , keys_duplicated  = []
+    , keys_unsupported = []
+    } =
+        hope_kv_list:find_unique_presence_violations(DictMissing, KeysRequired).
This page took 0.025939 seconds and 4 git commands to generate.