MCPcopy
hub / github.com/pocketbase/pocketbase / TestHookUnbindAll

Function TestHookUnbindAll

tools/hook/hook_test.go:104–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestHookUnbindAll(t *testing.T) {
105 h := Hook[*Event]{}
106
107 h.UnbindAll() // should do nothing and not panic
108
109 h.BindFunc(func(e *Event) error { return nil })
110 h.BindFunc(func(e *Event) error { return nil })
111
112 if total := len(h.handlers); total != 2 {
113 t.Fatalf("Expected %d handlers before UnbindAll, found %d", 2, total)
114 }
115
116 h.UnbindAll()
117
118 if total := len(h.handlers); total != 0 {
119 t.Fatalf("Expected no handlers after UnbindAll, found %d", total)
120 }
121}
122
123func TestHookTriggerErrorPropagation(t *testing.T) {
124 err := errors.New("test")

Callers

nothing calls this directly

Calls 2

UnbindAllMethod · 0.80
BindFuncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…