From 64eeeb749483f6bc999a2104b04183bd8c56e491 Mon Sep 17 00:00:00 2001 From: Dennis Zhuang Date: Mon, 25 Mar 2024 10:05:39 -0700 Subject: [PATCH] chore: verify status code --- .../test/emqx_bridge_greptimedb_SUITE.erl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/emqx_bridge_greptimedb/test/emqx_bridge_greptimedb_SUITE.erl b/apps/emqx_bridge_greptimedb/test/emqx_bridge_greptimedb_SUITE.erl index cabea247b..0fd839b7c 100644 --- a/apps/emqx_bridge_greptimedb/test/emqx_bridge_greptimedb_SUITE.erl +++ b/apps/emqx_bridge_greptimedb/test/emqx_bridge_greptimedb_SUITE.erl @@ -324,7 +324,7 @@ query_by_clientid(Topic, ClientId, Config) -> {"Content-Type", "application/x-www-form-urlencoded"} ], Body = <<"sql=select * from \"", Topic/binary, "\" where clientid='", ClientId/binary, "'">>, - {ok, _, _Headers, RawBody0} = + {ok, StatusCode, _Headers, RawBody0} = ehttpc:request( EHttpcPoolName, post, @@ -343,12 +343,12 @@ query_by_clientid(Topic, ClientId, Config) -> } } ] - } -> + } when StatusCode >= 200 andalso StatusCode =< 300 -> make_row(Schema, Rows); #{ <<"code">> := Code, <<"error">> := Error - } -> + } when StatusCode > 300 -> GreptimedbName = ?config(greptimedb_name, Config), Type = greptimedb_type_bin(?config(greptimedb_type, Config)), BridgeId = emqx_bridge_resource:bridge_id(Type, GreptimedbName), @@ -366,7 +366,9 @@ query_by_clientid(Topic, ClientId, Config) -> _ -> %% Table not found #{} - end + end; + Error -> + {error, Error} end. make_row(null, _Rows) ->