Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
Solomon Hykes authored on 2014/02/25 05:26:56... | ... |
@@ -29,6 +29,10 @@ func Register(name string, handler Handler) error { |
29 | 29 |
return nil |
30 | 30 |
} |
31 | 31 |
|
32 |
+func unregister(name string) { |
|
33 |
+ delete(globalHandlers, name) |
|
34 |
+} |
|
35 |
+ |
|
32 | 36 |
// The Engine is the core of Docker. |
33 | 37 |
// It acts as a store for *containers*, and allows manipulation of these |
34 | 38 |
// containers by executing *jobs*. |
... | ... |
@@ -16,6 +16,8 @@ func TestRegister(t *testing.T) { |
16 | 16 |
if err := Register("dummy1", nil); err == nil { |
17 | 17 |
t.Fatalf("Expecting error, got none") |
18 | 18 |
} |
19 |
+ // Register is global so let's cleanup to avoid conflicts |
|
20 |
+ defer unregister("dummy1") |
|
19 | 21 |
|
20 | 22 |
eng := newTestEngine(t) |
21 | 23 |
|
... | ... |
@@ -32,6 +34,7 @@ func TestRegister(t *testing.T) { |
32 | 32 |
if err := eng.Register("dummy2", nil); err == nil { |
33 | 33 |
t.Fatalf("Expecting error, got none") |
34 | 34 |
} |
35 |
+ defer unregister("dummy2") |
|
35 | 36 |
} |
36 | 37 |
|
37 | 38 |
func TestJob(t *testing.T) { |
... | ... |
@@ -48,6 +51,7 @@ func TestJob(t *testing.T) { |
48 | 48 |
} |
49 | 49 |
|
50 | 50 |
eng.Register("dummy2", h) |
51 |
+ defer unregister("dummy2") |
|
51 | 52 |
job2 := eng.Job("dummy2", "--level=awesome") |
52 | 53 |
|
53 | 54 |
if job2.handler == nil { |