package metrics import ( "testing" "github.com/prometheus/client_golang/prometheus/collectors" "github.com/stretchr/testify/assert" ) func TestOptions(t *testing.T) { t.Run("Basic", func(t *testing.T) { r := NewRecorder("test") assert.NotNil(t, r.reconcileConditionGauge) assert.Nil(t, r.reconcileConditionGaugeWithReason) assert.Equal(t, 2, len(r.collectors)) }) t.Run("WithSuspend", func(t *testing.T) { r := NewRecorder("test", WithSuspend()) assert.NotNil(t, r.suspendGauge) assert.Equal(t, 3, len(r.collectors)) }) t.Run("WithCollectors", func(t *testing.T) { r := NewRecorder("test", WithCollectors( collectors.NewGoCollector(), collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}), )) assert.Equal(t, 4, len(r.collectors), "Custom collectors weren't added to Recorder.collectors") }) t.Run("WithReason", func(t *testing.T) { r := NewRecorder("test", WithReason()) assert.NotNil(t, r.reconcileConditionGaugeWithReason) assert.Nil(t, r.reconcileConditionGauge) assert.Equal(t, 2, len(r.collectors)) }) }