helper/schema: full object test for addrToSchema

This commit is contained in:
Mitchell Hashimoto 2015-01-09 17:43:44 -08:00
parent e57f3f69b1
commit e9a4aaaca7
3 changed files with 13 additions and 4 deletions

View File

@ -58,7 +58,8 @@ func addrToSchema(addr []string, schemaMap map[string]*Schema) []*Schema {
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 {
return []*Schema{current}
}

View File

@ -42,10 +42,7 @@ func (r *MultiLevelFieldReader) ReadFieldMerge(
var result FieldReadResult
for _, l := range r.Levels {
if r, ok := r.Readers[l]; ok {
println(fmt.Sprintf("GET %#v %s %#v", address, l, r))
out, err := r.ReadField(address)
println(fmt.Sprintf("%#v", out))
println("======================================")
if err != nil {
return FieldReadResult{}, fmt.Errorf(
"Error reading level %s: %s", l, err)

View File

@ -11,6 +11,17 @@ func TestAddrToSchema(t *testing.T) {
Schema map[string]*Schema
Result []ValueType
}{
"full object": {
[]string{},
map[string]*Schema{
"list": &Schema{
Type: TypeList,
Elem: &Schema{Type: TypeInt},
},
},
[]ValueType{typeObject},
},
"list": {
[]string{"list"},
map[string]*Schema{