-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_for_test.go
63 lines (50 loc) · 1.35 KB
/
utils_for_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package poteto
import (
"errors"
"net/http"
)
func sampleMiddleware(next HandlerFunc) HandlerFunc {
return func(ctx Context) error {
res := ctx.GetResponse()
res.Header().Set("Hello", "world")
return next(ctx)
}
}
func sampleMiddleware2(next HandlerFunc) HandlerFunc {
return func(ctx Context) error {
res := ctx.GetResponse()
res.Header().Set("Hello2", "world2")
return next(ctx)
}
}
type user struct {
Name string `json:"string"`
}
type testVal struct {
Name string `json:"name"`
Val string `json:"val"`
}
func getAllUserForTest(ctx Context) error {
user := user{
Name: "user",
}
return ctx.JSON(http.StatusOK, user)
}
func throwError(ctx Context) error {
return errors.New("error")
}
func getAllUserForTestById(ctx Context) error {
user := user{
Name: "user1",
}
return ctx.JSON(http.StatusOK, user)
}
const (
userJSON = `{"name":"poteto"}`
rpcJSONId = `{"id":1}`
rpcJSONVersion = `{"id":1, "jsonrpc":"2.0"}`
rpcJSONMethod = `{"id":1, "jsonrpc":"2.0", "method":"Hello"}`
rpcJSONMethodClass = `{"id":1, "jsonrpc":"2.0", "method":"BestCalculator.Add"}`
rpcJSONMethodWrong = `{"id":1, "jsonrpc":"2.0", "method":"TestCalculator.Hello"}`
rpcJSONParams = `{"id":1, "jsonrpc":"2.0", "method":"TestCalculator.Add", "params":{"Added": 1}}`
)