Skip to content

Commit

Permalink
sort to avoid flacky test
Browse files Browse the repository at this point in the history
Signed-off-by: crowu <y.wu4515@gmail.com>
  • Loading branch information
5antelope committed Nov 24, 2020
1 parent 03740a6 commit 239b868
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions go/stats/statsd/statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,13 @@ func TestStatsdCountersWithSingleLabel(t *testing.T) {
if err != nil {
t.Fatal(err)
}
result := string(bytes[:n])
result := strings.Split(string(bytes[:n]), "\n")
sort.Strings(result)
expected := []string{
"test.counter_with_single_label_name:0|c|#label:tag2",
"test.counter_with_single_label_name:2|c|#label:tag1",
}
res := strings.Split(result, "\n")
sort.Strings(res)
for i, res := range res {
for i, res := range result {
assert.Equal(t, res, expected[i])
}
}
Expand Down Expand Up @@ -260,12 +259,13 @@ func TestStatsdCountersFuncWithMultiLabels(t *testing.T) {
if err != nil {
t.Fatal(err)
}
result := string(bytes[:n])
result := strings.Split(string(bytes[:n]), "\n")
sort.Strings(result)
expected := []string{
"test.counter_func_with_multiple_labels_name:1|c|#label1:foo,label2:bar",
"test.counter_func_with_multiple_labels_name:2|c|#label1:bar,label2:baz",
}
for i, res := range strings.Split(result, "\n") {
for i, res := range result {
assert.Equal(t, res, expected[i])
}
}
Expand Down Expand Up @@ -327,14 +327,13 @@ func TestStatsdGaugesFuncWithMultiLabels(t *testing.T) {
if err != nil {
t.Fatal(err)
}
result := string(bytes[:n])
result := strings.Split(string(bytes[:n]), "\n")
sort.Strings(result)
expected := []string{
"test.gauges_func_with_multiple_labels_name:1.000000|g|#label1:foo,label2:bar",
"test.gauges_func_with_multiple_labels_name:2.000000|g|#label1:bar,label2:baz",
}
res := strings.Split(result, "\n")
sort.Strings(res)
for i, res := range res {
for i, res := range result {
assert.Equal(t, res, expected[i])
}
}
Expand Down

0 comments on commit 239b868

Please sign in to comment.