Skip to content

Commit 4dce5ea

Browse files
committed
use custom controller registry in tests
1 parent 9fe972e commit 4dce5ea

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

controllers/alert_controller_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
"github.com/fluxcd/pkg/ssa"
3030
. "github.com/onsi/gomega"
31+
"github.com/prometheus/client_golang/prometheus"
3132
"github.com/sethvargo/go-limiter/memorystore"
3233
prommetrics "github.com/slok/go-http-metrics/metrics/prometheus"
3334
"github.com/slok/go-http-metrics/middleware"
@@ -168,9 +169,12 @@ func TestAlertReconciler_EventHandler(t *testing.T) {
168169
)
169170
g.Expect(createNamespace(namespace)).NotTo(HaveOccurred(), "failed to create test namespace")
170171

172+
reg := prometheus.NewRegistry()
173+
171174
eventMdlw := middleware.New(middleware.Config{
172175
Recorder: prommetrics.NewRecorder(prommetrics.Config{
173-
Prefix: "gotk_event",
176+
Prefix: "gotk_event",
177+
Registry: reg,
174178
}),
175179
})
176180

@@ -434,9 +438,12 @@ func TestAlertReconciler_EventHandler_CrossNamespaceRefs(t *testing.T) {
434438
)
435439
g.Expect(createNamespace(namespace)).NotTo(HaveOccurred(), "failed to create test namespace")
436440

441+
reg := prometheus.NewRegistry()
442+
437443
eventMdlw := middleware.New(middleware.Config{
438444
Recorder: prommetrics.NewRecorder(prommetrics.Config{
439-
Prefix: "gotk_event",
445+
Prefix: "gotk_event",
446+
Registry: reg,
440447
}),
441448
})
442449

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
github.com/ktrysmt/go-bitbucket v0.9.55
2525
github.com/microsoft/azure-devops-go-api/azuredevops/v6 v6.0.1
2626
github.com/onsi/gomega v1.27.2
27+
github.com/prometheus/client_golang v1.14.0
2728
github.com/sethvargo/go-limiter v0.7.2
2829
github.com/slok/go-http-metrics v0.10.0
2930
github.com/spf13/pflag v1.0.5
@@ -110,7 +111,6 @@ require (
110111
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
111112
github.com/pkg/errors v0.9.1 // indirect
112113
github.com/pmezard/go-difflib v1.0.0 // indirect
113-
github.com/prometheus/client_golang v1.14.0 // indirect
114114
github.com/prometheus/client_model v0.3.0 // indirect
115115
github.com/prometheus/common v0.37.0 // indirect
116116
github.com/prometheus/procfs v0.8.0 // indirect

0 commit comments

Comments
 (0)