-
Notifications
You must be signed in to change notification settings - Fork 0
/
c_test.go
98 lines (88 loc) · 2.52 KB
/
c_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package rpcsv
import (
// "encoding/json"
"fmt"
"github.com/toukii/goutils"
"net"
"net/rpc"
"testing"
)
var (
lis net.Listener
rpc_tcp_server = "rpchub.t0.daoapp.io:61142"
// rpc_tcp_server = "127.0.0.1:8800"
)
func init() {
// lis, _ = RPCServe("8800")
// lis, _ = RPCServeWithCode("8800")
}
func TestC(t *testing.T) {
return
t.Parallel()
in := []byte("# [Hello](http://mdblog.daoapp.io/)")
out := make([]byte, 10)
addr, err := net.ResolveTCPAddr("tcp", rpc_tcp_server)
if goutils.CheckErr(err) {
return
}
conn, err := net.DialTCP("tcp", nil, addr)
defer conn.Close()
if goutils.CheckErr(err) {
return
}
rc := rpc.NewClient(conn)
err = rc.Call("RPC.Markdown", &in, &out)
if goutils.CheckErr(err) {
return
}
fmt.Println(string(out))
}
func TestRPC(t *testing.T) {
return
t.Parallel()
c := RPCClientWithCodec(rpc_tcp_server)
defer c.Close()
in := []byte("# [Hi](http://mdblog.daoapp.io/)")
out := make([]byte, 10)
Markdown(c, &in, &out)
fmt.Println(goutils.ToString(out))
// defer lis.Close()
}
func TestAJob(t *testing.T) {
t.Parallel()
// return
c := RPCClientWithCodec(rpc_tcp_server)
defer c.Close()
in := Job{Name: "docker", Target: "https://www.google.com/search?q=docker+ci&oq=docker+ci&aqs=chrome..69i57j69i60l4.1517j0j4&sourceid=chrome&ie=UTF-8"}
// in := Job{Name: "docker", Target: "https://www.google.com/aclk?sa=l&ai=Cls_gs3pMV8qDGcuq9gWdmIDoBprG9PcJgp_wutwC7MbsFAgAEAFgibPGhPQToAG8ppTsA8gBAaoEJk_QWc_UQjNHKe39e-t7guvDvFwTnmO55c8m1AmJHWa40wgOFtPpgAes2esTkAcBqAemvhvYBwE&sig=AOD64_1CJPrrkYMy7tE2O8DDMb1KMt8GuQ&clui=0&ved=0ahUKEwiagI7aq4LNAhXhnaYKHX5UDeQQ0QwIEg&adurl=https://circleci.com/integrations/docker/"}
// in := Job{Name: "jenkins2", Target: "https://jenkins.io/solutions/docker/"}
// in := Job{Name: "jenkins-docker", Target: "https://youtu.be/ppCzDDpcqRk"}
out := make([]byte, 10)
err := c.Call("RPC.AJob", &in, &out)
goutils.CheckErr(err)
fmt.Println(in)
fmt.Println(goutils.ToString(out))
}
func TestWall(t *testing.T) {
return
t.Parallel()
c := RPCClientWithCodec(rpc_tcp_server)
defer c.Close()
out := Job{}
in := make([]byte, 1)
err := c.Call("RPC.Wall", &in, &out)
goutils.CheckErr(err)
fmt.Println("out:", out)
}
func TestWallBack(t *testing.T) {
// return
t.Parallel()
c := RPCClientWithCodec(rpc_tcp_server)
defer c.Close()
job := Job{Name: "mdblog", Result: goutils.ToByte("mdblog-result")}
out := make([]byte, 10)
// in := make([]byte, 1)
err := c.Call("RPC.WallBack", &job, &out)
goutils.CheckErr(err)
fmt.Println("out:", goutils.ToString(out))
}