mirror of
https://github.com/volatiletech/authboss.git
synced 2024-11-28 08:58:38 +02:00
f12f10fa43
- This change was necessary because multi-tenancy sites could not use authboss properly.
52 lines
1.2 KiB
Go
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)
|
|
}
|
|
}
|