Exemplo n.º 1
0
func (s *LogsSuite) TestLastSentLoggerSetGet(c *gc.C) {
	logger0 := state.NewLastSentLogger(s.State, "test-sink0")
	logger1 := state.NewLastSentLogger(s.State, "test-sink1")
	t := time.Date(2016, 04, 15, 16, 0, 0, 42, time.UTC)
	err := logger0.Set(t)
	c.Assert(err, jc.ErrorIsNil)
	t1, err := logger0.Get()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(t1, gc.DeepEquals, t)
	t2 := t.Add(time.Hour)
	err = logger0.Set(t2)
	c.Assert(err, jc.ErrorIsNil)
	t3, err := logger0.Get()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(t3, gc.DeepEquals, t2)
	_, err = logger1.Get()
	c.Assert(err, gc.ErrorMatches, state.ErrNeverForwarded.Error())

	t5 := time.Date(2016, 4, 15, 16, 0, 0, 43, time.Local)
	err = logger1.Set(t5)
	c.Assert(err, jc.ErrorIsNil)
	t6, err := logger1.Get()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(t6, gc.DeepEquals, t5.UTC())
}
Exemplo n.º 2
0
func (s *LogsSuite) TestLastSentLoggerNoSet(c *gc.C) {
	logger := state.NewLastSentLogger(s.State, "test")
	_, err := logger.Get()
	c.Assert(err, gc.ErrorMatches, state.ErrNeverForwarded.Error())
}