From 94e7c95b21623f3d0a8fcf1f5f670d2fc5dd998c Mon Sep 17 00:00:00 2001 From: Simon Sawert Date: Sun, 1 Oct 2023 22:50:54 +0200 Subject: [PATCH] Fix unreliable test --- inferrer_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inferrer_test.go b/inferrer_test.go index 8e24967..4d08374 100644 --- a/inferrer_test.go +++ b/inferrer_test.go @@ -5,6 +5,7 @@ import ( jtd "github.com/jsontypedef/json-typedef-go" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestJTDInfer(t *testing.T) { @@ -49,6 +50,17 @@ func TestJTDInferrerWithEnumHints(t *testing.T) { } gotSchema := InferStrings(rows, hints).IntoSchema(hints) + // We check that we got the same elements in our enum first and then we + // delete it since the order is unreliable due to being a map. + require.ElementsMatch( + t, + expectedSchema.Properties["address"].Properties["city"].Enum, + gotSchema.Properties["address"].Properties["city"].Enum, + ) + + delete(expectedSchema.Properties, "address") + delete(gotSchema.Properties, "address") + assert.EqualValues(t, expectedSchema, gotSchema) }