From a173d89ffabacbf286a76b6a64086c729f655e80 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 17 Jan 2023 17:59:58 +0100 Subject: [PATCH] added test for map of slice --- bundle/schema/schema_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/bundle/schema/schema_test.go b/bundle/schema/schema_test.go index 144daab13..333d79a64 100644 --- a/bundle/schema/schema_test.go +++ b/bundle/schema/schema_test.go @@ -378,6 +378,31 @@ func TestMapOfMapSchema(t *testing.T) { assert.Equal(t, expected, string(jsonSchema)) } +func TestMapOfSliceSchema(t *testing.T) { + var elem map[string][]string + + schema, err := NewSchema(reflect.TypeOf(elem)) + assert.NoError(t, err) + + jsonSchema, err := json.MarshalIndent(schema, " ", " ") + assert.NoError(t, err) + + expected := + `{ + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }` + + 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"`