nickva commented on code in PR #4474:
URL: https://github.com/apache/couchdb/pull/4474#discussion_r1134498987


##########
src/couch_prometheus/src/couch_prometheus_util.erl:
##########
@@ -167,3 +167,75 @@ val(Data) ->
 val(Key, Stats) ->
     {Key, Data} = lists:keyfind(Key, 1, Stats),
     val(Data).
+
+-ifdef(TEST).
+-include_lib("couch/include/couch_eunit.hrl").
+
+to_prom_test_() ->
+    [
+        ?_assertEqual(
+            <<"couchdb_ddoc_cache 10">>,
+            test_to_prom_output(ddoc_cache, counter, 10)
+        ),
+        ?_assertEqual(

Review Comment:
   The tests setup looks unnecessarily complicated -- since we don't do any 
setup or teardown, they can be simpler.
   
   ```erlang
   to_prom_ddoc_cache_test() ->
      ?assertEqual(<<"couchdb_ddoc_cache 10">>, prom_out(ddoc_cache, counter, 
10)).
   
   to_prom_gauge_test() ->
      ?assertEqual(...)
   ```
   
   Or grouped but without the `test_` (generator format) as simple assert 
statements:
   
   ```erlang
   to_prom_test() ->
         ?assertEqual(<<"couchdb_ddoc_cache 10">>, prom_out(ddoc_cache, 
counter, 10)),
         ?assertEqual(<<"couchdb_temperature_celsius 36">>, 
prom_out(temperature_celsius, gauge, 36)),
         ...
   ```
     



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to