Add test cases for new/1, all/0 functions

This commit is contained in:
Feng Lee 2019-09-20 23:25:19 +08:00
parent 8ef7f04d26
commit d945ee4972
1 changed files with 24 additions and 0 deletions

View File

@ -24,6 +24,30 @@
all() -> emqx_ct:all(?MODULE). all() -> emqx_ct:all(?MODULE).
t_new(_) ->
with_metrics_server(
fun() ->
ok = emqx_metrics:new('metrics.test'),
0 = emqx_metrics:val('metrics.test'),
ok = emqx_metrics:inc('metrics.test'),
1 = emqx_metrics:val('metrics.test'),
ok = emqx_metrics:new(counter, 'metrics.test.cnt'),
0 = emqx_metrics:val('metrics.test.cnt'),
ok = emqx_metrics:inc('metrics.test.cnt'),
1 = emqx_metrics:val('metrics.test.cnt'),
ok = emqx_metrics:new(gauge, 'metrics.test.total'),
0 = emqx_metrics:val('metrics.test.total'),
ok = emqx_metrics:inc('metrics.test.total'),
1 = emqx_metrics:val('metrics.test.total')
end).
t_all(_) ->
with_metrics_server(
fun() ->
Metrics = emqx_metrics:all(),
?assert(length(Metrics) > 50)
end).
t_inc_dec(_) -> t_inc_dec(_) ->
with_metrics_server( with_metrics_server(
fun() -> fun() ->