Exemple #1
0
func (s *FlagSuite) TestClaimError(c *gc.C) {
	var stub testing.Stub
	stub.SetErrors(errors.New("squish"))

	worker, err := singular.NewFlagWorker(singular.FlagConfig{
		Facade:   newStubFacade(&stub),
		Clock:    &fakeClock{},
		Duration: time.Hour,
	})
	c.Check(worker, gc.IsNil)
	c.Check(err, gc.ErrorMatches, "squish")
}
Exemple #2
0
func (fix *fixture) Run(c *gc.C, test testFunc) {
	facade := newStubFacade(&fix.Stub)
	clock := coretesting.NewClock(time.Now())
	flagWorker, err := singular.NewFlagWorker(singular.FlagConfig{
		Facade:   facade,
		Clock:    clock,
		Duration: time.Minute,
	})
	c.Assert(err, jc.ErrorIsNil)

	done := make(chan struct{})
	go func() {
		defer close(done)
		defer worker.Stop(flagWorker)
		defer facade.unblock()
		test(flagWorker, clock, facade.unblock)
	}()
	select {
	case <-done:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("test timed out")
	}
}