1
0
Fork 0
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:
Solomon Hykes 2014-02-24 12:26:56 -08:00
parent f14f4aa509
commit 62b21daded
2 changed files with 8 additions and 0 deletions

View file

@ -29,6 +29,10 @@ func Register(name string, handler Handler) error {
return nil
}
func unregister(name string) {
delete(globalHandlers, name)
}
// The Engine is the core of Docker.
// It acts as a store for *containers*, and allows manipulation of these
// containers by executing *jobs*.

View file

@ -16,6 +16,8 @@ func TestRegister(t *testing.T) {
if err := Register("dummy1", nil); err == nil {
t.Fatalf("Expecting error, got none")
}
// Register is global so let's cleanup to avoid conflicts
defer unregister("dummy1")
eng := newTestEngine(t)
@ -32,6 +34,7 @@ func TestRegister(t *testing.T) {
if err := eng.Register("dummy2", nil); err == nil {
t.Fatalf("Expecting error, got none")
}
defer unregister("dummy2")
}
func TestJob(t *testing.T) {
@ -48,6 +51,7 @@ func TestJob(t *testing.T) {
}
eng.Register("dummy2", h)
defer unregister("dummy2")
job2 := eng.Job("dummy2", "--level=awesome")
if job2.handler == nil {