aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/stub/exit_test.go
blob: 502197123b14bc406b7a2c89427f042ebbb7c7bc (plain)
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
package stub_test

import (
	"testing"

	"hakurei.app/container/stub"
)

func TestHandleExit(t *testing.T) {
	t.Run("exit", func(t *testing.T) {
		defer stub.HandleExit()
		panic(stub.PanicExit)
	})

	t.Run("nil", func(t *testing.T) {
		defer stub.HandleExit()
	})

	t.Run("passthrough", func(t *testing.T) {
		defer func() {
			want := 0xcafebabe
			if r := recover(); r != want {
				t.Errorf("recover: %v, want %v", r, want)
			}

		}()
		defer stub.HandleExit()
		panic(0xcafebabe)
	})
}