@@ -14,6 +14,7 @@ import (
14
14
"github.com/kyma-project/nats-manager/pkg/nats/mocks"
15
15
"github.com/kyma-project/nats-manager/testutils"
16
16
natsgo "github.com/nats-io/nats.go"
17
+ ptestutil "github.com/prometheus/client_golang/prometheus/testutil"
17
18
"github.com/stretchr/testify/mock"
18
19
"github.com/stretchr/testify/require"
19
20
"go.uber.org/zap"
@@ -218,6 +219,10 @@ func Test_handleNATSDeletion(t *testing.T) {
218
219
testEnv := NewMockedUnitTestEnvironment (t , objs ... )
219
220
reconciler := testEnv .Reconciler
220
221
222
+ // set values in metrics, which should be reset by the method.
223
+ reconciler .collector .RecordAvailabilityZonesUsedMetric (5 )
224
+ reconciler .collector .RecordClusterSizeMetric (5 )
225
+
221
226
nats := givenNats .DeepCopy ()
222
227
223
228
// define mocks behaviour
@@ -266,6 +271,15 @@ func Test_handleNATSDeletion(t *testing.T) {
266
271
require .True (t , nmapiv1alpha1 .ConditionEquals (* gotCondition , * tc .wantCondition ))
267
272
}
268
273
274
+ // check that metrics are reset.
275
+ gotAZMetric , err := reconciler .collector .GetAvailabilityZonesUsedMetric ()
276
+ require .NoError (t , err )
277
+ require .Equal (t , 0.0 , ptestutil .ToFloat64 (gotAZMetric ))
278
+
279
+ gotSizeMetric , err := reconciler .collector .GetClusterSizeMetric ()
280
+ require .NoError (t , err )
281
+ require .Equal (t , 0.0 , ptestutil .ToFloat64 (gotSizeMetric ))
282
+
269
283
// check k8s events
270
284
gotEvents := testEnv .GetK8sEvents ()
271
285
require .Equal (t , tc .wantK8sEvents , gotEvents )
0 commit comments