1
0
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:
Aaron
2015-01-14 19:18:45 -08:00
parent d9bcf5326c
commit 670c6f3b9f
6 changed files with 168 additions and 6 deletions

View File

@ -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.")
}
}