MCPcopy Create free account
hub / github.com/git-bug/git-bug / TestRegisterAndErrorAtCleaning

Function TestRegisterAndErrorAtCleaning

util/interrupt/cleaner_test.go:12–36  ·  view source on GitHub ↗

TestRegisterAndErrorAtCleaning tests if the registered order was kept by checking the returned errors

(t *testing.T)

Source from the content-addressed store, hash-verified

10
11// TestRegisterAndErrorAtCleaning tests if the registered order was kept by checking the returned errors
12func TestRegisterAndErrorAtCleaning(t *testing.T) {
13 handlerCreated = true // this prevents goroutine from being started during the tests
14
15 f1 := func() error {
16 return errors.New("1")
17 }
18 f2 := func() error {
19 return errors.New("2")
20 }
21 f3 := func() error {
22 return nil
23 }
24
25 RegisterCleaner(f1)
26 RegisterCleaner(f2)
27 RegisterCleaner(f3)
28
29 errl := clean()
30
31 require.Len(t, errl, 2)
32
33 // cleaners should execute in the reverse order they have been defined
34 assert.Equal(t, "2", errl[0].Error())
35 assert.Equal(t, "1", errl[1].Error())
36}
37
38func TestRegisterAndClean(t *testing.T) {
39 handlerCreated = true // this prevents goroutine from being started during the tests

Callers

nothing calls this directly

Calls 5

RegisterCleanerFunction · 0.85
cleanFunction · 0.85
NewMethod · 0.45
LenMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected