Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(275)

Unified Diff: worker/simpleworker_test.go

Issue 67080043: Simpleworker implemention
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« worker/simpleworker.go ('K') | « worker/simpleworker.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
+}
« worker/simpleworker.go ('K') | « worker/simpleworker.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b