add test failing to marshal json schema

This commit is contained in:
bukowa 2021-04-25 23:41:23 +02:00
parent 82cb4ebfe2
commit 370ddcbdf1

View File

@ -1,6 +1,7 @@
package schema_test
import (
"encoding/json"
"strings"
"sync"
"testing"
@ -297,3 +298,20 @@ func TestEmbeddedStructForCustomizedNamingStrategy(t *testing.T) {
})
}
}
func TestSchemaParseMarshalJson(t *testing.T) {
type model struct {
gorm.Model
Title string
}
v := &model{Title: "test"}
schema, err := schema.Parse(v, &sync.Map{}, schema.NamingStrategy{})
if err != nil {
t.Fatalf("error while parsing schema %v", err)
}
_, err = json.MarshalIndent(schema, "", "\t")
if err != nil {
t.Fatalf("error while json marshaling schema %v", err)
}
}