helper/schema: full object test for addrToSchema
This commit is contained in:
parent
e57f3f69b1
commit
e9a4aaaca7
|
@ -58,7 +58,8 @@ func addrToSchema(addr []string, schemaMap map[string]*Schema) []*Schema {
|
||||||
Elem: schemaMap,
|
Elem: schemaMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test
|
// If we aren't given an address, then the user is requesting the
|
||||||
|
// full object, so we return the special value which is the full object.
|
||||||
if len(addr) == 0 {
|
if len(addr) == 0 {
|
||||||
return []*Schema{current}
|
return []*Schema{current}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,7 @@ func (r *MultiLevelFieldReader) ReadFieldMerge(
|
||||||
var result FieldReadResult
|
var result FieldReadResult
|
||||||
for _, l := range r.Levels {
|
for _, l := range r.Levels {
|
||||||
if r, ok := r.Readers[l]; ok {
|
if r, ok := r.Readers[l]; ok {
|
||||||
println(fmt.Sprintf("GET %#v %s %#v", address, l, r))
|
|
||||||
out, err := r.ReadField(address)
|
out, err := r.ReadField(address)
|
||||||
println(fmt.Sprintf("%#v", out))
|
|
||||||
println("======================================")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FieldReadResult{}, fmt.Errorf(
|
return FieldReadResult{}, fmt.Errorf(
|
||||||
"Error reading level %s: %s", l, err)
|
"Error reading level %s: %s", l, err)
|
||||||
|
|
|
@ -11,6 +11,17 @@ func TestAddrToSchema(t *testing.T) {
|
||||||
Schema map[string]*Schema
|
Schema map[string]*Schema
|
||||||
Result []ValueType
|
Result []ValueType
|
||||||
}{
|
}{
|
||||||
|
"full object": {
|
||||||
|
[]string{},
|
||||||
|
map[string]*Schema{
|
||||||
|
"list": &Schema{
|
||||||
|
Type: TypeList,
|
||||||
|
Elem: &Schema{Type: TypeInt},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[]ValueType{typeObject},
|
||||||
|
},
|
||||||
|
|
||||||
"list": {
|
"list": {
|
||||||
[]string{"list"},
|
[]string{"list"},
|
||||||
map[string]*Schema{
|
map[string]*Schema{
|
||||||
|
|
Loading…
Reference in New Issue