-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpand_test.go
74 lines (64 loc) · 1.37 KB
/
expand_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
64
65
66
67
68
69
70
71
72
73
74
package easy_http
import (
"fmt"
"testing"
"time"
)
func TestClientPostJson(t *testing.T) {
builder := NewClientBuilder()
client, err := builder.Build()
if err != nil {
panic(err)
}
type T struct {
Name string `json:"name"`
}
tt := &T{Name: "aaaaaaaa"}
response := client.PostJson("http://127.0.0.1:8088", tt)
fmt.Println(response.Error())
}
func callback(resp IResponse) {
if resp.Error() != nil {
panic(resp.Error())
}
fmt.Println(string(resp.Content()))
}
func TestClient_PostJsonAsyn(t *testing.T) {
builder := NewClientBuilder()
client, err := builder.Build()
if err != nil {
panic(err)
}
type T struct {
Name string `json:"name"`
}
tt := &T{Name: "aaaaaaaa"}
err = client.PostJsonAsyn("http://127.0.0.1:8088", tt, callback)
if err != nil {
panic(err)
}
time.Sleep(5 * time.Second)
}
type PostJsonCallback struct{}
func (p PostJsonCallback) EasyResponseCallback(resp IResponse) {
if resp.Error() != nil {
panic(resp.Error())
}
fmt.Println(string(resp.Content()))
}
func TestClient_PostJsonAsynWithCallback(t *testing.T) {
builder := NewClientBuilder()
client, err := builder.Build()
if err != nil {
panic(err)
}
type T struct {
Name string `json:"name"`
}
tt := &T{Name: "aaaaaaaa"}
err = client.PostJsonAsynWithCallback("http://127.0.0.1:8088", tt, &PostJsonCallback{})
if err != nil {
panic(err)
}
time.Sleep(5 * time.Second)
}