Skip to content

Commit

Permalink
Fix unstable test case
Browse files Browse the repository at this point in the history
I see the test case TestAddLabelClient is unstable.
this is due to the labels order has been
shuffled after convertions between []string
and model.LabelSet, which is of map type.
  • Loading branch information
hienvanhuynh authored and jacksontj committed Sep 23, 2024
1 parent 114942b commit c7352ac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/promclient/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"reflect"
"slices"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -272,8 +273,8 @@ func TestAddLabelClient(t *testing.T) {
t.Fatalf("mismatch in len: \nexpected=%v\nactual=%v", test.labelNames, v)
}

for i, actualV := range v {
if actualV != test.labelNames[i] {
for _, actualV := range v {
if !slices.Contains(test.labelNames, actualV) {
t.Fatalf("mismatch in value: \nexpected=%v\nactual=%v", test.labelNames, v)
}
}
Expand Down

0 comments on commit c7352ac

Please sign in to comment.