Skip to content

Commit

Permalink
use custom controller registry in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alekspog committed Mar 30, 2023
1 parent 9fe972e commit 4dce5ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions controllers/alert_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

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

reg := prometheus.NewRegistry()

eventMdlw := middleware.New(middleware.Config{
Recorder: prommetrics.NewRecorder(prommetrics.Config{
Prefix: "gotk_event",
Prefix: "gotk_event",
Registry: reg,
}),
})

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

reg := prometheus.NewRegistry()

eventMdlw := middleware.New(middleware.Config{
Recorder: prommetrics.NewRecorder(prommetrics.Config{
Prefix: "gotk_event",
Prefix: "gotk_event",
Registry: reg,
}),
})

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/ktrysmt/go-bitbucket v0.9.55
github.com/microsoft/azure-devops-go-api/azuredevops/v6 v6.0.1
github.com/onsi/gomega v1.27.2
github.com/prometheus/client_golang v1.14.0
github.com/sethvargo/go-limiter v0.7.2
github.com/slok/go-http-metrics v0.10.0
github.com/spf13/pflag v1.0.5
Expand Down Expand Up @@ -110,7 +111,6 @@ require (
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
Expand Down

0 comments on commit 4dce5ea

Please sign in to comment.