mirror of
https://github.com/volatiletech/authboss.git
synced 2025-07-15 01:24:33 +02:00
Add more to context.
- Add test coverage to various modules.
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
package authboss
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCallbacks(t *testing.T) {
|
||||
afterCalled := false
|
||||
@ -36,3 +39,32 @@ func TestCallbacks(t *testing.T) {
|
||||
t.Error("Expected after to be called.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCallbacksInterrupt(t *testing.T) {
|
||||
before1 := false
|
||||
before2 := false
|
||||
c := NewCallbacks()
|
||||
|
||||
errValue := errors.New("Problem occured.")
|
||||
|
||||
c.Before(EventRegister, func(ctx *Context) error {
|
||||
before1 = true
|
||||
return errValue
|
||||
})
|
||||
c.Before(EventRegister, func(ctx *Context) error {
|
||||
before2 = true
|
||||
return nil
|
||||
})
|
||||
|
||||
err := c.FireBefore(EventRegister, NewContext())
|
||||
if err != errValue {
|
||||
t.Error("Expected an error to come back.")
|
||||
}
|
||||
|
||||
if !before1 {
|
||||
t.Error("Before1 should have been called.")
|
||||
}
|
||||
if before2 {
|
||||
t.Error("Before2 should not have been called.")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user