Beispiel #1
0
func (s *metricsManagerSuite) TestSendMetrics(c *gc.C) {
	var called bool
	metricsmanager.PatchFacadeCall(s, s.manager, func(request string, args, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "SendMetrics")
		result := response.(*params.ErrorResults)
		result.Results = make([]params.ErrorResult, 1)
		return nil
	})
	err := s.manager.SendMetrics()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, jc.IsTrue)
}
Beispiel #2
0
func (s *metricsManagerSuite) TestSendMetricsFails(c *gc.C) {
	var called bool
	metricsmanager.PatchFacadeCall(s, s.manager, func(request string, args, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "SendMetrics")
		result := response.(*params.ErrorResults)
		result.Results = make([]params.ErrorResult, 1)
		result.Results[0].Error = common.ServerError(common.ErrPerm)
		return result.OneError()
	})
	err := s.manager.SendMetrics()
	c.Assert(err, gc.ErrorMatches, "permission denied")
	c.Assert(called, jc.IsTrue)
}