config/module: tree.Child on a nil tree works

pull/9388/head
Mitchell Hashimoto 10 years ago
parent ba751c4e3b
commit 55ef966b88
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A

@ -66,6 +66,10 @@ func (t *Tree) Config() *config.Config {
// Child returns the child with the given path (by name).
func (t *Tree) Child(path []string) *Tree {
if t == nil {
return nil
}
if len(path) == 0 {
return t
}

@ -12,6 +12,11 @@ import (
)
func TestTreeChild(t *testing.T) {
var nilTree *Tree
if nilTree.Child(nil) != nil {
t.Fatal("child should be nil")
}
storage := testStorage(t)
tree := NewTree("", testConfig(t, "child"))
if err := tree.Load(storage, GetModeGet); err != nil {

Loading…
Cancel
Save