func (s *settingsSuite) TestDelete(c *gc.C) { settings := uniter.NewSettings(s.uniter, "blah", "foo", nil) settings.Set("foo", "qaz") settings.Set("abc", "tink") settings.Set("bar", "tonk") c.Assert(settings.Map(), gc.DeepEquals, params.RelationSettings{ "foo": "qaz", "abc": "tink", "bar": "tonk", }) settings.Delete("abc") c.Assert(settings.Map(), gc.DeepEquals, params.RelationSettings{ "foo": "qaz", "bar": "tonk", }) settings.Delete("bar") c.Assert(settings.Map(), gc.DeepEquals, params.RelationSettings{ "foo": "qaz", }) settings.Set("abc", "123") c.Assert(settings.Map(), gc.DeepEquals, params.RelationSettings{ "foo": "qaz", "abc": "123", }) settings.Delete("missing") c.Assert(settings.Map(), gc.DeepEquals, params.RelationSettings{ "foo": "qaz", "abc": "123", }) }
func (s *settingsSuite) TestNewSettingsAndMap(c *gc.C) { // Make sure newSettings accepts nil settings. settings := uniter.NewSettings(s.uniter, "blah", "foo", nil) theMap := settings.Map() c.Assert(theMap, gc.NotNil) c.Assert(theMap, gc.HasLen, 0) // And also accepts a populated map, and returns a converted map. rawSettings := params.RelationSettings{ "some": "settings", "other": "stuff", } settings = uniter.NewSettings(s.uniter, "blah", "foo", rawSettings) theMap = settings.Map() c.Assert(theMap, gc.DeepEquals, rawSettings) }
func (s *settingsSuite) TestSet(c *gc.C) { settings := uniter.NewSettings(s.uniter, "blah", "foo", nil) settings.Set("foo", "bar") c.Assert(settings.Map(), gc.DeepEquals, params.RelationSettings{ "foo": "bar", }) settings.Set("foo", "qaz") c.Assert(settings.Map(), gc.DeepEquals, params.RelationSettings{ "foo": "qaz", }) settings.Set("bar", "Cheers") c.Assert(settings.Map(), gc.DeepEquals, params.RelationSettings{ "foo": "qaz", "bar": "Cheers", }) }