-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_helper.go
48 lines (38 loc) · 861 Bytes
/
test_helper.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
package zebra
import (
"fmt"
"net/http"
"testing"
)
type TestHelper interface {
AssertTrue(bool)
AssertFalse(bool)
AssertEqual(string, string)
NewRequest(string, string) *http.Request
}
type testHelper struct {
t *testing.T
}
func NewTestHelper(t *testing.T) TestHelper {
return &testHelper{t}
}
func (helper *testHelper) AssertTrue(val bool) {
if !val {
helper.err("// TODO Error Message!")
}
}
func (helper *testHelper) AssertFalse(val bool) {
helper.AssertTrue(!val)
}
func (helper *testHelper) AssertEqual(des, obj string) {
if des != obj {
helper.err(fmt.Sprintf(` want "%s", but "%s" `, des, obj))
}
}
func (helper *testHelper) NewRequest(method, path string) *http.Request {
req, _ := http.NewRequest(method, "http://localhost:3000"+path, nil)
return req
}
func (helper *testHelper) err(msg string) {
helper.t.Error(msg)
}