fix(bpapi): Return undefined for unknown API on the node
This commit is contained in:
parent
d4785553b9
commit
c2d03838e2
|
@ -69,9 +69,12 @@ start() ->
|
||||||
announce(emqx).
|
announce(emqx).
|
||||||
|
|
||||||
%% @doc Get maximum version of the backplane API supported by the node
|
%% @doc Get maximum version of the backplane API supported by the node
|
||||||
-spec supported_version(node(), api()) -> api_version().
|
-spec supported_version(node(), api()) -> api_version() | undefined.
|
||||||
supported_version(Node, API) ->
|
supported_version(Node, API) ->
|
||||||
ets:lookup_element(?TAB, {Node, API}, #?TAB.version).
|
case ets:lookup(?TAB, {Node, API}) of
|
||||||
|
[#?TAB{version = V}] -> V;
|
||||||
|
[] -> undefined
|
||||||
|
end.
|
||||||
|
|
||||||
%% @doc Get maximum version of the backplane API supported by the
|
%% @doc Get maximum version of the backplane API supported by the
|
||||||
%% entire cluster
|
%% entire cluster
|
||||||
|
|
|
@ -40,7 +40,7 @@ end_per_suite(_Config) ->
|
||||||
t_max_supported_version(_Config) ->
|
t_max_supported_version(_Config) ->
|
||||||
?assertMatch(3, emqx_bpapi:supported_version('fake-node2@localhost', api2)),
|
?assertMatch(3, emqx_bpapi:supported_version('fake-node2@localhost', api2)),
|
||||||
?assertMatch(2, emqx_bpapi:supported_version(api2)),
|
?assertMatch(2, emqx_bpapi:supported_version(api2)),
|
||||||
?assertError(_, emqx_bpapi:supported_version('fake-node2@localhost', nonexistent_api)),
|
?assertMatch(undefined, emqx_bpapi:supported_version('fake-node2@localhost', nonexistent_api)),
|
||||||
?assertError(_, emqx_bpapi:supported_version(nonexistent_api)).
|
?assertError(_, emqx_bpapi:supported_version(nonexistent_api)).
|
||||||
|
|
||||||
t_announce(Config) ->
|
t_announce(Config) ->
|
||||||
|
|
Loading…
Reference in New Issue