-
Notifications
You must be signed in to change notification settings - Fork 0
/
errinternalservererror_test.go
49 lines (39 loc) · 955 Bytes
/
errinternalservererror_test.go
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
package errhttp_test
import (
"testing"
"net/http"
"github.com/reiver/go-errhttp"
)
func TestErrInternalServerError(t *testing.T) {
var err error = errhttp.ErrInternalServerError
casted := err.(errhttp.InternalServerError)
var code int = http.StatusInternalServerError
{
e := casted.Unwrap()
if nil != e {
t.Errorf("Expected the .Unwrap() to return nil but it actually didn't.")
t.Logf("ERROR: (%T) %s", e, e)
return
}
}
{
expected := code
actual := casted.ErrHTTP()
if expected != actual {
t.Errorf("The actual HTTP status-code is not what was expected.")
t.Logf("EXPECTED: %d", expected)
t.Logf("ACTUAL: %d", actual)
return
}
}
{
expected := http.StatusText(casted.ErrHTTP())
actual := err.Error()
if expected != actual {
t.Errorf("The actual error message was not what was expected.")
t.Logf("EXPECTED: %q", expected)
t.Logf("ACTUAL: %q", actual)
return
}
}
}