Exemplo n.º 1
0
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",
	})
}
Exemplo n.º 2
0
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)
}
Exemplo n.º 3
0
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",
	})
}