From d6a30c9f2fd6346a2243adbaf7273cabb8e919e1 Mon Sep 17 00:00:00 2001 From: Brett Hazen Date: Wed, 3 Feb 2016 04:41:08 +0000 Subject: [PATCH] RTS-890: Change expected error message for ts_simple_select_unexpected_token_not_allowed --- tests/ts_simple_select_unexpected_token_not_allowed.erl | 4 ++-- tests/ts_util.erl | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/ts_simple_select_unexpected_token_not_allowed.erl b/tests/ts_simple_select_unexpected_token_not_allowed.erl index ed164f00..b102df96 100644 --- a/tests/ts_simple_select_unexpected_token_not_allowed.erl +++ b/tests/ts_simple_select_unexpected_token_not_allowed.erl @@ -33,7 +33,7 @@ confirm() -> Qry = "selectah * from GeoCheckin " "Where time > 1 and time < 10", - {error, Got} = ts_util:ts_query( + Got = ts_util:ts_query( ts_util:cluster_and_connect(single), TestType, DDL, Data, Qry), - ?assertNotEqual(0, string:str(binary_to_list(Got), "Unexpected token")), + ts_util:assert_error_regex({error, {1020, <<".*Unexpected token.*">>}}, Got), pass. diff --git a/tests/ts_util.erl b/tests/ts_util.erl index b5e5e776..d5c85165 100644 --- a/tests/ts_util.erl +++ b/tests/ts_util.erl @@ -25,6 +25,7 @@ activate_bucket_type/2, activate_bucket_type/3, assert/3, + assert_error_regex/2, assert_float/3, build_cluster/1, cluster_and_connect/1, @@ -496,6 +497,14 @@ assert(String, Exp, Got) -> lager:info("*****************", []), lager:info("*****************", []), fail. +%% Match an error code and use a regex to match the error string +assert_error_regex({error, {Code, Regex}}, {error, {Code, Msg}}) -> + {ok, RE} = re:compile(Regex), + Match = re:run(Msg, RE), + ?assertNotEqual(Match, nomatch); +assert_error_regex(Got, Expected) -> + ?assertEqual(Got, Expected). + results(Results) -> Expected = lists:duplicate(length(Results), pass), ?assertEqual(Expected, Results).