Просмотр исходного кода

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

Feng Lee 6 лет назад
Родитель
Сommit
d945ee4972
1 измененных файлов с 24 добавлено и 0 удалено
  1. 24 0
      test/emqx_metrics_SUITE.erl

+ 24 - 0
test/emqx_metrics_SUITE.erl

@@ -24,6 +24,30 @@
 
 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(_) ->
     with_metrics_server(
       fun() ->