test: add license cli test

This commit is contained in:
Zhongwen Deng 2023-05-29 18:19:59 +08:00
parent 2d2062e504
commit e065904583
3 changed files with 28 additions and 2 deletions

View File

@ -2,7 +2,7 @@
{application, emqx_dashboard, [
{description, "EMQX Web Dashboard"},
% strict semver, bump manually!
{vsn, "5.0.21"},
{vsn, "5.0.22"},
{modules, []},
{registered, [emqx_dashboard_sup]},
{applications, [kernel, stdlib, mnesia, minirest, emqx, emqx_ctl]},

View File

@ -3,7 +3,7 @@
{id, "emqx_machine"},
{description, "The EMQX Machine"},
% strict semver, bump manually!
{vsn, "0.2.4"},
{vsn, "0.2.5"},
{modules, []},
{registered, []},
{applications, [kernel, stdlib, emqx_ctl]},

View File

@ -53,3 +53,29 @@ t_update(_Config) ->
_ = emqx_license_cli:license(["update", LicenseValue]),
_ = emqx_license_cli:license(["reload"]),
_ = emqx_license_cli:license(["update", "Invalid License Value"]).
t_conf_update(_Config) ->
ok = persistent_term:put(
emqx_license_test_pubkey,
emqx_license_test_lib:public_key_pem()
),
LicenseKey = emqx_license_test_lib:make_license(#{max_connections => "123"}),
Conf = #{
<<"connection_high_watermark">> => <<"50%">>,
<<"connection_low_watermark">> => <<"45%">>,
<<"key">> => LicenseKey
},
?assertMatch({ok, _}, emqx:update_config([license], Conf)),
?assertEqual(
#{
connection_high_watermark => 0.5,
connection_low_watermark => 0.45,
key => LicenseKey
},
emqx:get_config([license])
),
?assertMatch(
#{max_connections := 123},
maps:from_list(emqx_license_checker:dump())
),
ok.