-
Notifications
You must be signed in to change notification settings - Fork 0
/
kinds_test.go
46 lines (35 loc) · 1 KB
/
kinds_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
package re
import (
"errors"
"net/http"
"testing"
)
func TestAddKind(t *testing.T) {
const KindTesting Kind = "testing"
AddKind(KindTesting, 200)
got, has := kinds[KindTesting]
if !has {
t.Errorf("excpexted to has the %s as a kind", KindTesting)
}
if got != 200 {
t.Errorf("excpexted to has %v as the value of kind %s", 200, KindTesting)
}
}
func TestHttpCode(t *testing.T) {
const KindOutOfNowhere Kind = "out of no where"
bag := New("testing operation", errors.New("no new err"), KindOutOfNowhere)
gotCode := HttpCode(bag)
if gotCode != http.StatusInternalServerError {
t.Errorf("non declared kind wrong http code")
}
bag2 := New("testing operation", errors.New("no new err"))
gotCode2 := HttpCode(bag2)
if gotCode2 != http.StatusInternalServerError {
t.Errorf("default kind wrong http code")
}
bag3 := New("testing operation", errors.New("no new err"), KindForbidden)
gotCode3 := HttpCode(bag3)
if gotCode3 != http.StatusForbidden {
t.Errorf("declared kind wrong http code")
}
}