-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathparse_test.go
60 lines (50 loc) · 1.15 KB
/
parse_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
package p2pubapi
import (
"testing"
"github.com/iij/p2pubapi/protocol"
)
type TCommon struct {
Hello string `json:"-"`
World string `json:"-"`
InJson string
InParam string `json:"-" p2pub:",query"`
}
func (t TCommon) URI() string {
return "/a/p/i/{{.Hello}}/{{.World}}.json"
}
func (t TCommon) APIName() string {
return "helloworld"
}
func (t TCommon) JPName() string {
return "はろう"
}
func (t TCommon) Method() string {
return "GET"
}
func (t TCommon) Document() string {
return "http://www.example.com"
}
func Test1(t *testing.T) {
t.Log("hello")
cmn := TCommon{Hello: "hello", World: "world", InJson: "in-json"}
cmn.Hello = "hello"
cmn.World = "world"
cmn.InJson = "test value"
cmn.InParam = "test param"
api := NewAPI("accesskey", "secretkey")
t.Log("body", GetBody(cmn))
t.Log("path", GetPath(cmn))
param := GetParam(*api, cmn)
t.Log("param", param)
}
func TestAPIList(t *testing.T) {
for _, a := range protocol.APIlist {
t.Logf("%v %v %v", a.Method(), a.APIName(), a.URI())
req, opt := ArgumentList(a)
t.Log("req", req, "opt", opt)
}
arg := protocol.VMGet{}
err := Validate(arg)
t.Log(err)
t.Log(ArgumentList(arg))
}