Skip to content

Commit

Permalink
Tests for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
dkeysil committed Feb 2, 2024
1 parent 726d82a commit 1757fe7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions domain/metrics_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package domain

import "testing"

func TestIsMetricAllowed(t *testing.T) {
tests := []struct {
name string
metric string
want bool
}{
{
name: "Test with allowed metric",
metric: MetricClientDial,
want: true,
},
{
name: "Test with disallowed metric",
metric: "agent.client.unknown",
want: false,
},
{
name: "Test with allowed metric prefix",
metric: "jsonrpc.latency.chainId",
want: true,
},
{
name: "Test with disallowed metric prefix",
metric: "agent.unknown.",
want: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsMetricAllowed(tt.metric); got != tt.want {
t.Errorf("IsMetricAllowed() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 1757fe7

Please sign in to comment.