@@ -14,6 +14,7 @@ prometheus_format_test_() ->
1414 fun test_toggle /1 ,
1515 fun test_deregister /1 ,
1616 fun test_remove /1 ,
17+ fun test_match_remove /1 ,
1718 fun test_default_value /1 ,
1819 fun test_collector1 /1 ,
1920 fun test_collector2 /1 ,
@@ -66,7 +67,11 @@ test_errors(_) ->
6667 ? _assertError ({unknown_metric , default , unknown_metric },
6768 prometheus_boolean :remove (unknown_metric )),
6869 ? _assertError ({invalid_metric_arity , 2 , 1 },
69- prometheus_boolean :remove (with_label , [repo , db ]))
70+ prometheus_boolean :remove (with_label , [repo , db ])),
71+ ? _assertError ({unknown_metric , default , unknown_metric },
72+ prometheus_boolean :match_remove (unknown_metric )),
73+ ? _assertError ({invalid_metric_arity , 2 , 1 },
74+ prometheus_boolean :match_remove (with_label , [repo , db ], []))
7075 ].
7176
7277test_set (_ ) ->
@@ -145,6 +150,36 @@ test_remove(_) ->
145150 ? _assertEqual (false , RResult3 ),
146151 ? _assertEqual (false , RResult4 )].
147152
153+ test_match_remove (_ ) ->
154+ prometheus_boolean :new ([{name , fuse_state },
155+ {labels , [pool ]},
156+ {help , " " }]),
157+ prometheus_boolean :new ([{name , simple_boolean }, {help , " " }]),
158+
159+ prometheus_boolean :set (fuse_state , [mongodb ], true ),
160+ prometheus_boolean :set (simple_boolean , true ),
161+
162+ BRValue1 = prometheus_boolean :value (fuse_state , [mongodb ]),
163+ BRValue2 = prometheus_boolean :value (simple_boolean ),
164+
165+ RResult1 = prometheus_boolean :match_remove (fuse_state , ['$1' ], [{'=:=' ,'$1' , mongodb }]),
166+ RResult2 = prometheus_boolean :match_remove (simple_boolean ),
167+
168+ ARValue1 = prometheus_boolean :value (fuse_state , [mongodb ]),
169+ ARValue2 = prometheus_boolean :value (simple_boolean ),
170+
171+ RResult3 = prometheus_boolean :match_remove (fuse_state , ['$1' ], [{'=:=' ,'$1' , mongodb }]),
172+ RResult4 = prometheus_boolean :match_remove (simple_boolean ),
173+
174+ [? _assertEqual (true , BRValue1 ),
175+ ? _assertEqual (true , BRValue2 ),
176+ ? _assertEqual (1 , RResult1 ),
177+ ? _assertEqual (1 , RResult2 ),
178+ ? _assertEqual (undefined , ARValue1 ),
179+ ? _assertEqual (undefined , ARValue2 ),
180+ ? _assertEqual (0 , RResult3 ),
181+ ? _assertEqual (0 , RResult4 )].
182+
148183test_default_value (_ ) ->
149184 prometheus_boolean :new ([{name , fuse_state },
150185 {labels , [name ]},
0 commit comments