1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-07-13 01:20:17 +02:00

Add session and cookie concepts.

- Add tests for callbacks.
- Refactor callbacks into a keyed map.
This commit is contained in:
Aaron
2015-01-12 14:02:07 -08:00
parent 59454bf909
commit 7f9fe3ec77
9 changed files with 301 additions and 49 deletions

38
callbacks_test.go Normal file
View File

@ -0,0 +1,38 @@
package authboss
import "testing"
func TestCallbacks(t *testing.T) {
afterCalled := false
beforeCalled := false
c := NewCallbacks()
c.Before(EventRegister, func(ctx *Context) error {
beforeCalled = true
return nil
})
c.After(EventRegister, func(ctx *Context) {
afterCalled = true
})
if beforeCalled || afterCalled {
t.Error("Neither should be called.")
}
err := c.FireBefore(EventRegister, NewContext())
if err != nil {
t.Error("Unexpected error:", err)
}
if !beforeCalled {
t.Error("Expected before to have been called.")
}
if afterCalled {
t.Error("Expected after not to be called.")
}
c.FireAfter(EventRegister, NewContext())
if !afterCalled {
t.Error("Expected after to be called.")
}
}