forked from aarondl/authboss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
executable file
·51 lines (41 loc) · 1.18 KB
/
errors_test.go
File metadata and controls
executable file
·51 lines (41 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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)
}
}