Skip to content

Commit

Permalink
Merge pull request #620 from bboreham/test-string
Browse files Browse the repository at this point in the history
LabelSet: add unit test for String method
  • Loading branch information
ArthurSens committed Apr 18, 2024
2 parents e25b951 + a1ca958 commit e54e4df
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions model/labelset_test.go
Expand Up @@ -123,6 +123,38 @@ func TestLabelSetMerge(t *testing.T) {
}
}

func TestLabelSet_String(t *testing.T) {
tests := []struct {
input LabelSet
want string
}{
{
input: nil,
want: `{}`,
}, {
input: LabelSet{
"foo": "bar",
},
want: `{foo="bar"}`,
}, {
input: LabelSet{
"foo": "bar",
"foo2": "bar",
"abc": "prometheus",
"foo11": "bar11",
},
want: `{abc="prometheus", foo="bar", foo11="bar11", foo2="bar"}`,
},
}
for _, tt := range tests {
t.Run("test", func(t *testing.T) {
if got := tt.input.String(); got != tt.want {
t.Errorf("LabelSet.String() = %v, want %v", got, tt.want)
}
})
}
}

// Benchmark Results for LabelSet's String() method
// ---------------------------------------------------------------------------------------------------------
// goos: linux
Expand Down

0 comments on commit e54e4df

Please sign in to comment.