Make from_json_error_cases tests idiomatic
authorEric Avdey <eiri@eiri.ca>
Fri, 1 Feb 2019 16:39:42 +0000 (12:39 -0400)
committerEric Avdey <eiri@eiri.ca>
Tue, 5 Feb 2019 01:55:25 +0000 (21:55 -0400)
src/couch/test/couch_doc_json_tests.erl

index cc5dc32..848bae8 100644 (file)
@@ -288,18 +288,14 @@ from_json_error_cases() ->
 
     lists:map(fun
         ({Fun, Expect, Msg}) when is_function(Fun, 0) ->
-            Error = (catch couch_doc:from_json_obj_validate(Fun())),
-            {Msg, ?_assertMatch(Expect, Error)};
+            {Msg,
+            ?_assertThrow(Expect, couch_doc:from_json_obj_validate(Fun()))};
         ({EJson, Expect, Msg}) ->
-            Error = (catch couch_doc:from_json_obj_validate(EJson)),
-            {Msg, ?_assertMatch(Expect, Error)};
+            {Msg,
+            ?_assertThrow(Expect, couch_doc:from_json_obj_validate(EJson))};
         ({EJson, Msg}) ->
-            try
-                couch_doc:from_json_obj_validate(EJson),
-                {"Conversion failed to raise an exception", ?_assert(false)}
-            catch
-                _:_ -> {Msg, ?_assert(true)}
-            end
+            {Msg,
+            ?_assertThrow(_, couch_doc:from_json_obj_validate(EJson))}
     end, Cases).
 
 from_json_with_dbname_error_cases() ->