Exemplo n.º 1
0
func (s *ChainMapSuite) TestGet2(c *gc.C) {
	chainMap := chainmap.New(s.dict1, s.dict2)

	result := chainMap.Get("value")
	c.Assert(result, gc.Equals, "4")
	result = chainMap.Get("testing")
	c.Assert(result, gc.Equals, "2")
}
Exemplo n.º 2
0
// return a string value for the named option.  All % interpolations are
// expanded in the return values, based on the defaults passed into the
// constructor and the DEFAULT section.
func (p *ConfigParser) GetInterpolated(section, option string) (string, error) {
	o, err := p.Items(section)
	if err != nil {
		return "", err
	}
	c := chainmap.New(chainmap.Dict(p.Defaults()), chainmap.Dict(o))
	return p.getInterpolated(section, option, c)
}
Exemplo n.º 3
0
func (s *ChainMapSuite) TestGet3(c *gc.C) {
	chainMap := chainmap.New(s.dict2, s.dict1)

	result := chainMap.Get("value")
	c.Assert(result, gc.Equals, "3")
}
Exemplo n.º 4
0
func (s *ChainMapSuite) TestGet1(c *gc.C) {
	chainMap := chainmap.New(s.dict1, s.dict2)

	result := chainMap.Get("unknown")
	c.Assert(result, gc.Equals, "")
}
Exemplo n.º 5
0
func (s *ChainMapSuite) TestLen(c *gc.C) {
	chainMap := chainmap.New(s.dict1, s.dict2)
	c.Assert(chainMap.Len(), gc.Equals, 2)
}