blob: f839c0dcbf3175e8111118be978075ca8ba2899a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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")
}
}
|