Skip to content

Commit

Permalink
LabelSet: add unit test for String method
Browse files Browse the repository at this point in the history
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
  • Loading branch information
bboreham committed Apr 13, 2024
1 parent 0234594 commit a1ca958
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions model/labelset_test.go
Original file line number Diff line number Diff line change
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 a1ca958

Please sign in to comment.