-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_test.go
49 lines (42 loc) · 1.1 KB
/
check_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 check
import (
"mime/multipart"
"net/url"
)
var (
testAlpha = "PeWGHxQBZfiMVQNbWGzkegklTRMHVmuO"
testInt = "-19001231"
testFloat = "-19001231.558877"
testURL = "http://example.com"
testChecker = &Checker{
"email": {Required, Email},
"city": {Alpha},
"phone": {Phone},
"stars": {Required, Range(3, 5)},
"birthYear": {Max(2000)},
}
testCheckerData = &multipart.Form{Value: url.Values{
"name": {"foobar"},
"phone": {"0012345678901"},
"stars": {"2"},
"birthYear": {"2001"},
}}
testCheckerWant = Errors{
"email": {{Error: ErrRequired}},
"stars": {{Error: ErrMin, Args: []interface{}{"3"}}},
}
)
/*
func TestCheckerCheck(t *testing.T) {
got := testChecker.Check(testCheckerData)
if !reflect.DeepEqual(testCheckerWant, got) {
t.Errorf("Checker.Check:\nwant %v\ngot %v", testCheckerWant, got)
}
}
func TestCheckerCheckRequest(t *testing.T) {
got := testChecker.CheckRequest(&http.Request{MultipartForm: testCheckerData})
if !reflect.DeepEqual(testCheckerWant, got) {
t.Errorf("Checker.Check:\nwant %v\ngot %v", testCheckerWant, got)
}
}
*/