| Index: worker/simpleworker_test.go |
| === added file 'worker/simpleworker_test.go' |
| --- worker/simpleworker_test.go 1970-01-01 00:00:00 +0000 |
| +++ worker/simpleworker_test.go 2014-02-21 19:09:14 +0000 |
| @@ -0,0 +1,40 @@ |
| +// Copyright 2014 Canonical Ltd. |
| +// Licensed under the AGPLv3, see LICENCE file for details. |
| + |
| +package worker |
| + |
| +import ( |
| + "errors" |
| + |
| + gc "launchpad.net/gocheck" |
| + |
| + "launchpad.net/juju-core/testing/testbase" |
| +) |
| + |
| +type simpleWorkerSuite struct { |
| + testbase.LoggingSuite |
| +} |
| + |
| +var _ = gc.Suite(&simpleWorkerSuite{}) |
| + |
| +var testError = errors.New("test error") |
| + |
| +func (s *simpleWorkerSuite) TestWait(c *gc.C) { |
| + doWork := func(_ <-chan struct{}) error { |
| + return testError |
| + } |
| + |
| + w := NewSimpleWorker(doWork) |
| + c.Assert(w.Wait(), gc.Equals, testError) |
| +} |
| + |
| +func (s *simpleWorkerSuite) TestKill(c *gc.C) { |
| + doWork := func(stopCh <-chan struct{}) error { |
| + <-stopCh |
| + return nil |
| + } |
| + |
| + w := NewSimpleWorker(doWork) |
| + w.Kill() |
| + c.Assert(w.Wait(), gc.Equals, nil) |
| rog 2014/02/24 17:57:36 This isn't quite testing that we're waiting until natefinch 2014/02/24 19:26:43 Good point. Done. |
| +} |