Beispiel #1
0
// TestSend create 2 metrics, one sent and one not sent.
// It confirms that one metric is sent.
func (s *SenderSuite) TestSender(c *gc.C) {
	notify := make(chan string, 1)
	var client mockClient
	worker := metricworker.NewSender(&client, notify)
	select {
	case <-notify:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("the cleanup function should have fired by now")
	}
	c.Assert(client.calls, gc.DeepEquals, []string{"SendMetrics"})
	worker.Kill()
	c.Assert(worker.Wait(), gc.IsNil)
}
Beispiel #2
0
// TestSend create 2 metrics, one sent and one not sent.
// It confirms that one metric is sent.
func (s *SenderSuite) TestSender(c *gc.C) {
	notify := make(chan string)
	cleanup := metricworker.PatchNotificationChannel(notify)
	defer cleanup()
	client := &mockClient{}
	worker := metricworker.NewSender(client)
	select {
	case <-notify:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("the cleanup function should have fired by now")
	}
	c.Assert(client.calls, gc.DeepEquals, []string{"SendMetrics"})
	worker.Kill()
	c.Assert(worker.Wait(), gc.IsNil)
}