1
0
mirror of https://github.com/volatiletech/authboss.git synced 2024-12-10 10:40:07 +02:00
authboss/errors_test.go
Aaron f12f10fa43 Stop reliance on global scope.
- This change was necessary because multi-tenancy sites could not use
  authboss properly.
2015-03-31 12:34:03 -07:00

52 lines
1.2 KiB
Go

package authboss
import (
"errors"
"testing"
)
func TestAttributeErr(t *testing.T) {
t.Parallel()
estr := "Failed to retrieve database attribute, type was wrong: lol (want: String, got: int)"
if str := NewAttributeErr("lol", String, 5).Error(); str != estr {
t.Error("Error was wrong:", str)
}
estr = "Failed to retrieve database attribute: lol"
err := AttributeErr{Name: "lol"}
if str := err.Error(); str != estr {
t.Error("Error was wrong:", str)
}
}
func TestClientDataErr(t *testing.T) {
t.Parallel()
estr := "Failed to retrieve client attribute: lol"
err := ClientDataErr{"lol"}
if str := err.Error(); str != estr {
t.Error("Error was wrong:", str)
}
}
func TestErrAndRedirect(t *testing.T) {
t.Parallel()
estr := "Error: cause, Redirecting to: /"
err := ErrAndRedirect{errors.New("cause"), "/", "success", "failure"}
if str := err.Error(); str != estr {
t.Error("Error was wrong:", str)
}
}
func TestRenderErr(t *testing.T) {
t.Parallel()
estr := `Error rendering template "lol": cause, data: authboss.HTMLData{"a":5}`
err := RenderErr{"lol", NewHTMLData("a", 5), errors.New("cause")}
if str := err.Error(); str != estr {
t.Error("Error was wrong:", str)
}
}