Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
electron0zero committed Sep 27, 2024
1 parent 4239289 commit 40bd11f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/collector/distinct_string_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestDistinctStringCollector(t *testing.T) {
d.Collect("11")

require.True(t, d.Exceeded())
require.Equal(t, []string{"123", "4567", "890"}, d.Strings())
stringsSlicesEqual(t, []string{"123", "4567", "890"}, d.Strings())

// diff fails when diff is not enabled
res, err := d.Diff()
Expand All @@ -32,14 +32,14 @@ func TestDistinctStringCollectorDiff(t *testing.T) {
d.Collect("123")
d.Collect("4567")

require.Equal(t, []string{"123", "4567"}, readDistinctStringDiff(t, d))
require.Equal(t, []string{}, readDistinctStringDiff(t, d))
stringsSlicesEqual(t, []string{"123", "4567"}, readDistinctStringDiff(t, d))
stringsSlicesEqual(t, []string{}, readDistinctStringDiff(t, d))

d.Collect("123")
d.Collect("890")

require.Equal(t, []string{"890"}, readDistinctStringDiff(t, d))
require.Equal(t, []string{}, readDistinctStringDiff(t, d))
stringsSlicesEqual(t, []string{"890"}, readDistinctStringDiff(t, d))
stringsSlicesEqual(t, []string{}, readDistinctStringDiff(t, d))
}

func readDistinctStringDiff(t *testing.T, d *DistinctString) []string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/distinct_value_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDistinctValueCollector(t *testing.T) {

require.True(t, d.Exceeded())
require.Equal(t, stop, d.Exceeded()) // final stop should be same as Exceeded
require.Equal(t, []string{"123", "4567"}, d.Values())
stringsSlicesEqual(t, []string{"123", "4567"}, d.Values())

// diff fails when diff is not enabled
res, err := d.Diff()
Expand Down

0 comments on commit 40bd11f

Please sign in to comment.