Skip to content

Commit

Permalink
[chore][exporter/elasticsearch] fix flaky assertion in TestExporterMe…
Browse files Browse the repository at this point in the history
…trics (#35639)

#### Description

Sometimes the order of fields in the json strings change which causes
failures in the test.
  • Loading branch information
mauri870 authored Oct 9, 2024
1 parent a2b67d9 commit 256e465
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion exporter/elasticsearchexporter/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ func assertItemsEqual(t *testing.T, expected, actual []itemRequest, assertOrder
copy(actualItems, actual)
slices.SortFunc(actualItems, itemRequestsSortFunc)
}
assert.Equal(t, expectedItems, actualItems)

assert.Equal(t, len(expectedItems), len(actualItems), "want %d items, got %d", len(expectedItems), len(actualItems))
for i, want := range expectedItems {
got := actualItems[i]
assert.JSONEq(t, string(want.Action), string(got.Action), "item %d action", i)
assert.JSONEq(t, string(want.Document), string(got.Document), "item %d document", i)
}
}

type itemResponse struct {
Expand Down

0 comments on commit 256e465

Please sign in to comment.