Ejemplo n.º 1
0
func (s *ContextSuite) TestCtxDeclaredMetric(c *gc.C) {
	ctx := collect.NewHookContext("u/0", s.recorder)
	err := ctx.AddMetric("pings", "1", time.Now())
	c.Assert(err, jc.ErrorIsNil)
	err = ctx.Flush("", nil)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(s.recorder.closed, jc.IsTrue)
	c.Assert(s.recorder.batches, gc.HasLen, 1)
	c.Assert(s.recorder.batches[0].Metrics, gc.HasLen, 1)
	c.Assert(s.recorder.batches[0].Metrics[0].Key, gc.Equals, "pings")
	c.Assert(s.recorder.batches[0].Metrics[0].Value, gc.Equals, "1")
}
Ejemplo n.º 2
0
func (s *ContextSuite) TestHookContextEnv(c *gc.C) {
	ctx := collect.NewHookContext("u/0", s.recorder)
	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), "")
}