예제 #1
0
func (s *ContextSuite) TestHookContextEnv(c *gc.C) {
	ctx := meterstatus.NewLimitedContext("u/0")
	paths := &dummyPaths{}
	vars, err := ctx.HookVars(paths)
	c.Assert(err, jc.ErrorIsNil)
	varMap, err := keyvalues.Parse(vars, true)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(varMap["JUJU_AGENT_SOCKET"], gc.Equals, "/dummy/jujuc.sock")
	c.Assert(varMap["JUJU_UNIT_NAME"], gc.Equals, "u/0")
	key := "PATH"
	if runtime.GOOS == "windows" {
		key = "Path"
	}
	c.Assert(varMap[key], gc.Not(gc.Equals), "")
}
예제 #2
0
func (s *ContextSuite) TestHookContextSetEnv(c *gc.C) {
	ctx := meterstatus.NewLimitedContext("u/0")
	setVars := map[string]string{
		"somekey":    "somevalue",
		"anotherkey": "anothervalue",
	}
	ctx.SetEnvVars(setVars)
	paths := &dummyPaths{}
	vars, err := ctx.HookVars(paths)
	c.Assert(err, jc.ErrorIsNil)
	varMap, err := keyvalues.Parse(vars, true)
	c.Assert(err, jc.ErrorIsNil)
	for key, value := range setVars {
		c.Assert(varMap[key], gc.Equals, value)
	}
	c.Assert(varMap["JUJU_AGENT_SOCKET"], gc.Equals, "/dummy/jujuc.sock")
	c.Assert(varMap["JUJU_UNIT_NAME"], gc.Equals, "u/0")
}