Alexander "PapaTutuWawa
617b68f43e
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
25 lines
433 B
Go
25 lines
433 B
Go
package metrics
|
|
|
|
import (
|
|
"regexp"
|
|
"testing"
|
|
)
|
|
|
|
func TestShouldPing(t *testing.T) {
|
|
cfg := MetricConfig{
|
|
Enabled: true,
|
|
Url: "",
|
|
BotUserAgents: &[]regexp.Regexp{
|
|
*regexp.MustCompile("random-bot/.*"),
|
|
},
|
|
}
|
|
|
|
if cfg.ShouldSendMetrics("/index.html", "random-bot/v23.5") {
|
|
t.Fatalf("Accepted bot user-agent")
|
|
}
|
|
|
|
if !cfg.ShouldSendMetrics("/index.html", "Firefox/...") {
|
|
t.Fatalf("Rejected real user-agent")
|
|
}
|
|
}
|