MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestIncCounter

Function TestIncCounter

rpc/mux/server_test.go:109–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestIncCounter(t *testing.T) {
110 log.SetLevel(log.FatalLevel)
111 addr := "127.0.0.1:0"
112 l, err := net.Listen("tcp", addr)
113 if err != nil {
114 log.Fatal(err)
115 }
116
117 server, err := NewServerWithService(ServiceMap{"Test": NewTestService()})
118 server.SetListener(l)
119 go server.WithAcceptConnFunc(rpc.AcceptRawConn).Serve()
120
121 conn, err := net.Dial("tcp", l.Addr().String())
122 if err != nil {
123 log.Fatal(err)
124 }
125 stream, err := NewOneOffMuxConn(conn)
126 if err != nil {
127 log.Fatal(err)
128 }
129 client := rpc.NewClient(stream)
130
131 rep := new(TestRep)
132 err = client.Call("Test.IncCounter", &TestReq{Step: 10}, rep)
133 if err != nil {
134 log.Fatal(err)
135 }
136 CheckNum(rep.Ret, 10, t)
137
138 err = client.Call("Test.IncCounter", &TestReq{Step: 10}, rep)
139 if err != nil {
140 log.Fatal(err)
141 }
142 CheckNum(rep.Ret, 20, t)
143
144 repSimple := new(int32)
145 err = client.Call("Test.IncCounterSimpleArgs", 10, repSimple)
146 if err != nil {
147 log.Fatal(err)
148 }
149 CheckNum(*repSimple, 30, t)
150
151 _ = client.Close()
152 server.Stop()
153}
154
155func TestIncCounterSimpleArgs(t *testing.T) {
156 log.SetLevel(log.FatalLevel)

Callers

nothing calls this directly

Calls 15

CallMethod · 0.95
CloseMethod · 0.95
SetLevelFunction · 0.92
FatalFunction · 0.92
NewClientFunction · 0.92
NewOneOffMuxConnFunction · 0.85
SetListenerMethod · 0.80
AddrMethod · 0.80
NewServerWithServiceFunction · 0.70
NewTestServiceFunction · 0.70
CheckNumFunction · 0.70
ServeMethod · 0.45

Tested by

no test coverage detected