diff options
-rw-r--r-- | clients/common/common.go | 5 | ||||
-rw-r--r-- | clients/common/common_test.go | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/clients/common/common.go b/clients/common/common.go index ef35440..a6f6166 100644 --- a/clients/common/common.go +++ b/clients/common/common.go @@ -99,7 +99,10 @@ func (c *Capabilities) Get(capability string) *Capability { // Set sets a capability removing the values func (c *Capabilities) Set(capability string, values ...string) { - delete(c.m, capability) + if _, ok := c.m[capability]; ok { + delete(c.m, capability) + } + c.Add(capability, values...) } diff --git a/clients/common/common_test.go b/clients/common/common_test.go index dac15b6..c8dafe9 100644 --- a/clients/common/common_test.go +++ b/clients/common/common_test.go @@ -82,6 +82,13 @@ func (s *SuiteCommon) TestCapabilitiesSet(c *C) { c.Assert(cap.Get("symref").Values, DeepEquals, []string{"bar"}) } +func (s *SuiteCommon) TestCapabilitiesSetEmpty(c *C) { + cap := NewCapabilities() + cap.Set("foo", "bar") + + c.Assert(cap.Get("foo").Values, HasLen, 1) +} + func (s *SuiteCommon) TestCapabilitiesAdd(c *C) { cap := NewCapabilities() cap.Add("symref", "foo", "qux") |