config/module: tree.Child on a nil tree works
This commit is contained in:
parent
ba751c4e3b
commit
55ef966b88
|
@ -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…
Reference in New Issue