Skip to content

Commit

Permalink
add chamber tests
Browse files Browse the repository at this point in the history
  • Loading branch information
steviebps committed Apr 21, 2021
1 parent 370c74a commit c62d02e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pkg/chamber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ func TestFindByName(t *testing.T) {
bottom,
},
}
middle2 := &Chamber{
Name: "MIDDLE2",
}
top := &Chamber{
Name: "TOP",
Children: []*Chamber{
middle,
middle2,
},
}

Expand All @@ -27,6 +31,7 @@ func TestFindByName(t *testing.T) {
}{
{"BOTTOM", bottom},
{"MIDDLE", middle},
{"MIDDLE2", middle2},
{"TOP", top},
}

Expand All @@ -37,3 +42,45 @@ func TestFindByName(t *testing.T) {
}
}
}

func TestInheritWith(t *testing.T) {

bottom := &Chamber{
Name: "BOTTOM",
Toggles: map[string]*Toggle{
"toggle2": &Toggle{
Name: "toggle1",
ToggleType: "boolean",
Value: false,
},
},
}
top := &Chamber{
Name: "TOP",
Toggles: map[string]*Toggle{
"toggle1": &Toggle{
Name: "toggle1",
ToggleType: "boolean",
Value: false,
},
},
}
middle := &Chamber{
Name: "MIDDLE",
Toggles: map[string]*Toggle{
"toggle1": &Toggle{
Name: "toggle1",
ToggleType: "boolean",
Value: false,
},
},
}

middle.InheritWith(top.Toggles)
// should not inherit an already existent key
bottom.InheritWith(middle.Toggles)

if len(bottom.Toggles) != 2 {
t.Errorf("%q did not inherit properly from %q", bottom.Name, top.Name)
}
}

0 comments on commit c62d02e

Please sign in to comment.