From 91617e50c188d659bd8783b03dd3f95a45dacd41 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 17 Jan 2023 15:47:31 +0100 Subject: [PATCH] added test for map of primitives --- bundle/schema/schema_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bundle/schema/schema_test.go b/bundle/schema/schema_test.go index 93b3607aa..b6aeb702b 100644 --- a/bundle/schema/schema_test.go +++ b/bundle/schema/schema_test.go @@ -292,6 +292,28 @@ func TestStructOfSliceSchema(t *testing.T) { assert.Equal(t, expected, string(jsonSchema)) } +func TestMapOfPrimitivesSchema(t *testing.T) { + var elem map[string]int + + schema, err := NewSchema(reflect.TypeOf(elem)) + assert.NoError(t, err) + + jsonSchema, err := json.MarshalIndent(schema, " ", " ") + assert.NoError(t, err) + + expected := + `{ + "type": "object", + "additionalProperties": { + "type": "number" + } + }` + + t.Log("[DEBUG] actual: ", string(jsonSchema)) + t.Log("[DEBUG] expected: ", expected) + assert.Equal(t, expected, string(jsonSchema)) +} + func TestObjectSchema(t *testing.T) { type Person struct { Name string `json:"name"`