fix: the field 'enable' is missing for GET /bridges/:id

This commit is contained in:
Shawn 2022-04-28 18:13:19 +08:00
parent e18c2a6de2
commit 6edb453ce9
2 changed files with 14 additions and 3 deletions

View File

@ -648,11 +648,11 @@ fill_defaults(Type, RawConf) ->
unpack_bridge_conf(Type, FullConf).
pack_bridge_conf(Type, RawConf) ->
#{<<"bridges">> => #{Type => #{<<"foo">> => RawConf}}}.
#{<<"bridges">> => #{bin(Type) => #{<<"foo">> => RawConf}}}.
unpack_bridge_conf(Type, PackedConf) ->
#{<<"bridges">> := Bridges} = PackedConf,
#{<<"foo">> := RawConf} = maps:get(Type, Bridges),
#{<<"foo">> := RawConf} = maps:get(bin(Type), Bridges),
RawConf.
is_ok(ResL) ->
@ -689,4 +689,8 @@ error_msg(Code, Msg) ->
#{code => Code, message => bin(io_lib:format("~p", [Msg]))}.
bin(S) when is_list(S) ->
list_to_binary(S).
list_to_binary(S);
bin(S) when is_atom(S) ->
atom_to_binary(S, utf8);
bin(S) when is_binary(S) ->
S.

View File

@ -171,6 +171,7 @@ t_http_crud_apis(_) ->
#{
<<"type">> := ?BRIDGE_TYPE,
<<"name">> := ?BRIDGE_NAME,
<<"enable">> := true,
<<"status">> := _,
<<"node_status">> := [_ | _],
<<"metrics">> := _,
@ -208,6 +209,7 @@ t_http_crud_apis(_) ->
#{
<<"type">> := ?BRIDGE_TYPE,
<<"name">> := ?BRIDGE_NAME,
<<"enable">> := true,
<<"status">> := _,
<<"node_status">> := [_ | _],
<<"metrics">> := _,
@ -224,6 +226,7 @@ t_http_crud_apis(_) ->
#{
<<"type">> := ?BRIDGE_TYPE,
<<"name">> := ?BRIDGE_NAME,
<<"enable">> := true,
<<"status">> := _,
<<"node_status">> := [_ | _],
<<"metrics">> := _,
@ -240,6 +243,7 @@ t_http_crud_apis(_) ->
#{
<<"type">> := ?BRIDGE_TYPE,
<<"name">> := ?BRIDGE_NAME,
<<"enable">> := true,
<<"status">> := _,
<<"node_status">> := [_ | _],
<<"metrics">> := _,
@ -305,6 +309,7 @@ do_start_stop_bridges(Type) ->
#{
<<"type">> := ?BRIDGE_TYPE,
<<"name">> := ?BRIDGE_NAME,
<<"enable">> := true,
<<"status">> := <<"connected">>,
<<"node_status">> := [_ | _],
<<"metrics">> := _,
@ -349,6 +354,7 @@ t_enable_disable_bridges(_) ->
#{
<<"type">> := ?BRIDGE_TYPE,
<<"name">> := ?BRIDGE_NAME,
<<"enable">> := true,
<<"status">> := <<"connected">>,
<<"node_status">> := [_ | _],
<<"metrics">> := _,
@ -397,6 +403,7 @@ t_reset_bridges(_) ->
#{
<<"type">> := ?BRIDGE_TYPE,
<<"name">> := ?BRIDGE_NAME,
<<"enable">> := true,
<<"status">> := <<"connected">>,
<<"node_status">> := [_ | _],
<<"metrics">> := _,