diff options
Diffstat (limited to 'util/interrupt/cleaner_test.go')
-rw-r--r-- | util/interrupt/cleaner_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/util/interrupt/cleaner_test.go b/util/interrupt/cleaner_test.go new file mode 100644 index 00000000..f839c0dc --- /dev/null +++ b/util/interrupt/cleaner_test.go @@ -0,0 +1,33 @@ +package interrupt + +import ( + "testing" +) + +func TestRegister(t *testing.T) { + active = true // this prevents goroutine from being started during the tests + + f := func() error { + return nil + } + f2 := func() error { + return nil + } + f3 := func() error { + return nil + } + RegisterCleaner(f) + RegisterCleaner(f2, f3) + count := 0 + for _, fn := range cleaners { + errt := fn() + count++ + if errt != nil { + t.Fatalf("bad err value") + } + } + if count != 3 { + t.Fatalf("different number of errors") + } + +} |