Browse Source

Named EUnit test cases

Viktor Söderqvist 10 years ago
parent
commit
af3db59736
2 changed files with 27 additions and 21 deletions
  1. 20 16
      test/mysql_tests.erl
  2. 7 5
      test/transaction_tests.erl

+ 20 - 16
test/mysql_tests.erl

@@ -68,19 +68,21 @@ query_test_() ->
          ok = mysql:query(Pid, <<"DROP DATABASE otptest">>),
          exit(Pid, normal)
      end,
-     {with, [fun connect_with_db/1,
-             fun autocommit/1,
-             fun basic_queries/1,
-             fun text_protocol/1,
-             fun binary_protocol/1,
-             fun float_rounding/1,
-             fun decimal/1,
-             fun int/1,
-             fun bit/1,
-             fun date/1,
-             fun time/1,
-             fun datetime/1,
-             fun microseconds/1]}}.
+     fun (Pid) ->
+         [{"Select db on connect", fun () -> connect_with_db(Pid) end},
+          {"Autocommit",           fun () -> autocommit(Pid) end},
+          {"Basic queries",        fun () -> basic_queries(Pid) end},
+          {"Text protocol",        fun () -> text_protocol(Pid) end},
+          {"Binary protocol",      fun () -> binary_protocol(Pid) end},
+          {"FLOAT rounding",       fun () -> float_rounding(Pid) end},
+          {"DECIMAL",              fun () -> decimal(Pid) end},
+          {"INT",                  fun () -> int(Pid) end},
+          {"BIT(N)",               fun () -> bit(Pid) end},
+          {"DATE",                 fun () -> date(Pid) end},
+          {"TIME",                 fun () -> time(Pid) end},
+          {"DATETIME",             fun () -> datetime(Pid) end},
+          {"Microseconds",         fun () -> microseconds(Pid) end}]
+     end}.
 
 connect_with_db(_Pid) ->
     %% Make another connection and set the db in the handshake phase
@@ -93,7 +95,7 @@ connect_with_db(_Pid) ->
         mysql:query(Pid, <<"DROP TABLE IF EXISTS dummy">>)
     end),
     ?assertMatch([{_, "Note 1051: Unknown table 'dummy'\n"
-                      " in DROP TABLE IF EXISTS dummy" ++ _}],
+                      " in DROP TABLE IF EXISTS dummy\n"}],
                  LoggedErrors),
     exit(Pid, normal).
 
@@ -441,8 +443,10 @@ with_table_foo_test_() ->
          ok = mysql:query(Pid, <<"DROP DATABASE otptest">>),
          exit(Pid, normal)
      end,
-     {with, [fun prepared_statements/1,
-             fun parameterized_query/1]}}.
+     fun (Pid) ->
+         [{"Prepared statements", fun () -> prepared_statements(Pid) end},
+          {"Parametrized queries", fun () -> parameterized_query(Pid) end}]
+     end}.
 
 prepared_statements(Pid) ->
     %% Unnamed

+ 7 - 5
test/transaction_tests.erl

@@ -40,11 +40,13 @@ single_connection_test_() ->
          ok = mysql:query(Pid, <<"DROP DATABASE otptest">>),
          exit(Pid, normal)
      end,
-     {with, [fun simple_atomic/1,
-             fun simple_aborted/1,
-             fun nested_atomic/1,
-             fun nested_inner_aborted/1,
-             fun implicit_commit/1]}}.
+     fun (Pid) ->
+         [{"Simple atomic",        fun () -> simple_atomic(Pid) end},
+          {"Simple aborted",       fun () -> simple_aborted(Pid) end},
+          {"Nested atomic",        fun () -> nested_atomic(Pid) end},
+          {"Nested inner aborted", fun () -> nested_inner_aborted(Pid) end},
+          {"Implicit commit",      fun () -> implicit_commit(Pid) end}]
+     end}.
 
 simple_atomic(Pid) ->
     ?assertNot(mysql:in_transaction(Pid)),