mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Engine: cleanup side effects between tests
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
f14f4aa509
commit
62b21daded
2 changed files with 8 additions and 0 deletions
|
@ -29,6 +29,10 @@ func Register(name string, handler Handler) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unregister(name string) {
|
||||||
|
delete(globalHandlers, name)
|
||||||
|
}
|
||||||
|
|
||||||
// The Engine is the core of Docker.
|
// The Engine is the core of Docker.
|
||||||
// It acts as a store for *containers*, and allows manipulation of these
|
// It acts as a store for *containers*, and allows manipulation of these
|
||||||
// containers by executing *jobs*.
|
// containers by executing *jobs*.
|
||||||
|
|
|
@ -16,6 +16,8 @@ func TestRegister(t *testing.T) {
|
||||||
if err := Register("dummy1", nil); err == nil {
|
if err := Register("dummy1", nil); err == nil {
|
||||||
t.Fatalf("Expecting error, got none")
|
t.Fatalf("Expecting error, got none")
|
||||||
}
|
}
|
||||||
|
// Register is global so let's cleanup to avoid conflicts
|
||||||
|
defer unregister("dummy1")
|
||||||
|
|
||||||
eng := newTestEngine(t)
|
eng := newTestEngine(t)
|
||||||
|
|
||||||
|
@ -32,6 +34,7 @@ func TestRegister(t *testing.T) {
|
||||||
if err := eng.Register("dummy2", nil); err == nil {
|
if err := eng.Register("dummy2", nil); err == nil {
|
||||||
t.Fatalf("Expecting error, got none")
|
t.Fatalf("Expecting error, got none")
|
||||||
}
|
}
|
||||||
|
defer unregister("dummy2")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJob(t *testing.T) {
|
func TestJob(t *testing.T) {
|
||||||
|
@ -48,6 +51,7 @@ func TestJob(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
eng.Register("dummy2", h)
|
eng.Register("dummy2", h)
|
||||||
|
defer unregister("dummy2")
|
||||||
job2 := eng.Job("dummy2", "--level=awesome")
|
job2 := eng.Job("dummy2", "--level=awesome")
|
||||||
|
|
||||||
if job2.handler == nil {
|
if job2.handler == nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue