internal: fix the tests broken by hardening

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: If95a5258a393542564f68b3a1ebc7ff66a6a6964
This commit is contained in:
raf 2026-03-01 13:40:19 +03:00
commit da1fab4257
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
6 changed files with 17 additions and 17 deletions

View file

@ -9,7 +9,7 @@ import (
"notashelf.dev/watchdog/internal/config"
)
var prometheusLabelPattern = regexp.MustCompile(`^[a-zA-Z0-9_/:-]*$`)
var prometheusLabelPattern = regexp.MustCompile(`^[a-zA-Z0-9_/:.-]*$`)
// Records analytics events as Prometheus metrics
type MetricsAggregator struct {

View file

@ -22,7 +22,7 @@ func TestMetricsAggregator_RecordPageview(t *testing.T) {
},
}
agg := NewMetricsAggregator(registry, cfg)
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
// Record pageview with all dimensions
agg.RecordPageview("/home", "US", "desktop", "google.com")
@ -51,7 +51,7 @@ func TestMetricsAggregator_RecordPageview_MinimalDimensions(t *testing.T) {
},
}
agg := NewMetricsAggregator(registry, cfg)
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
// Record pageview with only path
agg.RecordPageview("/home", "", "", "")
@ -78,7 +78,7 @@ func TestMetricsAggregator_PathOverflow(t *testing.T) {
},
}
agg := NewMetricsAggregator(registry, cfg)
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
// Add two paths successfully
registry.Add("/path1")
@ -114,7 +114,7 @@ func TestMetricsAggregator_RecordCustomEvent(t *testing.T) {
},
}
agg := NewMetricsAggregator(registry, cfg)
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
// Record custom event
agg.RecordCustomEvent("signup")
@ -141,7 +141,7 @@ func TestMetricsAggregator_RecordCustomEvent_MultipleEvents(t *testing.T) {
},
}
agg := NewMetricsAggregator(registry, cfg)
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
// Record multiple events
agg.RecordCustomEvent("signup")
@ -170,7 +170,7 @@ func TestMetricsAggregator_MustRegister(t *testing.T) {
}
promRegistry := prometheus.NewRegistry()
agg := NewMetricsAggregator(registry, cfg)
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
// Register metrics
agg.MustRegister(promRegistry)