Skip to content

Commit 94e7c95

Browse files
committed
Fix unreliable test
1 parent ed0c80e commit 94e7c95

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

inferrer_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
jtd "github.com/jsontypedef/json-typedef-go"
77
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
89
)
910

1011
func TestJTDInfer(t *testing.T) {
@@ -49,6 +50,17 @@ func TestJTDInferrerWithEnumHints(t *testing.T) {
4950
}
5051
gotSchema := InferStrings(rows, hints).IntoSchema(hints)
5152

53+
// We check that we got the same elements in our enum first and then we
54+
// delete it since the order is unreliable due to being a map.
55+
require.ElementsMatch(
56+
t,
57+
expectedSchema.Properties["address"].Properties["city"].Enum,
58+
gotSchema.Properties["address"].Properties["city"].Enum,
59+
)
60+
61+
delete(expectedSchema.Properties, "address")
62+
delete(gotSchema.Properties, "address")
63+
5264
assert.EqualValues(t, expectedSchema, gotSchema)
5365
}
5466

0 commit comments

Comments
 (0)