internal/util: move FieldJSONInfo into jsonschema/util (#251)
This CL effectively removes any dependencies on mcp from jsonschema. This will enable us to move the repo. This CL also deletes unused marshalStructWithMap and unmarshalStructWithMap which had a dependency on FieldJSONInfo. Fixes: #250
This commit is contained in:
parent
e00c485969
commit
b392875dc5
1 changed files with 82 additions and 264 deletions
|
|
@ -184,3 +184,31 @@ func TestMarshalStructWithMap(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestJSONInfo(t *testing.T) {
|
||||
type S struct {
|
||||
A int
|
||||
B int `json:","`
|
||||
C int `json:"-"`
|
||||
D int `json:"-,"`
|
||||
E int `json:"echo"`
|
||||
F int `json:"foxtrot,omitempty"`
|
||||
g int `json:"golf"`
|
||||
}
|
||||
want := []jsonInfo{
|
||||
{name: "A"},
|
||||
{name: "B"},
|
||||
{omit: true},
|
||||
{name: "-"},
|
||||
{name: "echo"},
|
||||
{name: "foxtrot", settings: map[string]bool{"omitempty": true}},
|
||||
{omit: true},
|
||||
}
|
||||
tt := reflect.TypeFor[S]()
|
||||
for i := range tt.NumField() {
|
||||
got := fieldJSONInfo(tt.Field(i))
|
||||
if !reflect.DeepEqual(got, want[i]) {
|
||||
t.Errorf("got %+v, want %+v", got, want[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue