mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-02-22 16:25:43 +02:00
30 lines
394 B
Go
30 lines
394 B
Go
package hook
|
|
|
|
import "testing"
|
|
|
|
func TestEventNext(t *testing.T) {
|
|
calls := 0
|
|
|
|
e := Event{}
|
|
|
|
if e.nextFunc() != nil {
|
|
t.Fatalf("Expected nextFunc to be nil")
|
|
}
|
|
|
|
e.setNextFunc(func() error {
|
|
calls++
|
|
return nil
|
|
})
|
|
|
|
if e.nextFunc() == nil {
|
|
t.Fatalf("Expected nextFunc to be non-nil")
|
|
}
|
|
|
|
e.Next()
|
|
e.Next()
|
|
|
|
if calls != 2 {
|
|
t.Fatalf("Expected %d calls, got %d", 2, calls)
|
|
}
|
|
}
|