Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cmdutils/switches/switches.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,25 @@ func (s *Switches) Enabled(name string) bool {
// All returns names of all items set in settings
func (s *Switches) All() sets.String {
names := sets.NewString()
for k := range s.settings {
for k := range s.defaults {
names.Insert(k)
}

return names
}

// Active returns names of all active items
func (s *Switches) Active() sets.String {
names := sets.NewString()
for k, enabled := range s.settings {
if enabled {
names.Insert(k)
}
}

return names
}

// EnabledByDefault returns names of all enabled items
func (s *Switches) EnabledByDefault() sets.String {
names := sets.NewString()
Expand Down
11 changes: 9 additions & 2 deletions cmdutils/switches/switches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ var _ = Describe("CMD Switches", func() {
Expect(s.Enabled("runner-b")).To(BeFalse())
})
It("should return all items", func() {
s := New("runner-a", "runner-b")
s := New("runner-a", "runner-b", Disable("runner-c"))
Expect(s.Set("*,-runner-b")).ToNot(HaveOccurred())

expected := sets.NewString("runner-a", "runner-b")
expected := sets.NewString("runner-a", "runner-b", "runner-c")
Expect(s.All()).To(Equal(expected))
})
It("should return only active items", func() {
s := New("runner-a", "runner-b", Disable("runner-c"))
Expect(s.Set("*,-runner-b")).ToNot(HaveOccurred())

expected := sets.NewString("runner-a")
Expect(s.Active()).To(Equal(expected))
})
It("should return all enabled items", func() {
s := New("runner-a", Disable("runner-b"))

Expand Down