From 797168c3fcd14c3f2bd1e749b2cb1f96d467c414 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Mon, 27 Jan 2025 16:58:54 -0600 Subject: [PATCH] fix: flaky test `TestConvertToStructs` was occasionally failing because it was expecting `range` over a `map` to be a consistent order, but per [spec]: > The iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next. Uses `ElementsMatch` so the test passes even when the order of elements is different. [spec]: https://go.dev/ref/spec#RangeClause --- api/grpc/mpi/v1/helpers_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/grpc/mpi/v1/helpers_test.go b/api/grpc/mpi/v1/helpers_test.go index 62cfb0a90..e23aa8040 100644 --- a/api/grpc/mpi/v1/helpers_test.go +++ b/api/grpc/mpi/v1/helpers_test.go @@ -65,7 +65,7 @@ func TestConvertToStructs(t *testing.T) { t.Run(tt.name, func(t *testing.T) { got, err := ConvertToStructs(tt.input) - assert.Equal(t, tt.expected, got) + assert.ElementsMatch(t, tt.expected, got) assert.Equal(t, tt.wantErr, err != nil) }) }