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

Function TestRawCaller

rpc/mux/rawcaller_test.go:44–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestRawCaller(t *testing.T) {
45 Convey("test raw caller methods", t, func() {
46 s := NewServer().WithAcceptConnFunc(rpc.AcceptRawConn)
47 err := s.RegisterService("Test", &testService{})
48 So(err, ShouldBeNil)
49 l, err := net.Listen("tcp", ":0")
50 So(err, ShouldBeNil)
51 s.SetListener(l)
52 go s.Serve()
53 defer s.Stop()
54 c := NewRawCaller(l.Addr().String())
55 defer c.Close()
56 var resp int
57 err = c.Call("Test.Test", 1, &resp)
58 So(err, ShouldBeNil)
59 So(resp, ShouldEqual, 2)
60 err = c.Call("Test.TestFailed", 1, nil)
61 So(err, ShouldNotBeNil)
62 So(errors.Cause(err).Error(), ShouldEqual, "failed")
63 err = c.Call("Test.TestReconnect", 1, nil)
64 So(err, ShouldNotBeNil)
65 So(err.Error(), ShouldContainSubstring, "shut down")
66 So(c.Target(), ShouldEqual, l.Addr().String())
67 err = c.Call("Test.Test", 2, &resp)
68 So(err, ShouldBeNil)
69 So(resp, ShouldEqual, 3)
70
71 // test new client
72 c2 := c.New()
73 defer c2.Close()
74 err = c2.Call("Test.Test", 4, &resp)
75 So(err, ShouldBeNil)
76 So(resp, ShouldEqual, 5)
77 })
78}

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
CallMethod · 0.95
TargetMethod · 0.95
NewMethod · 0.95
NewRawCallerFunction · 0.85
RegisterServiceMethod · 0.80
SetListenerMethod · 0.80
AddrMethod · 0.80
ErrorMethod · 0.80
NewServerFunction · 0.70
CloseMethod · 0.65
CallMethod · 0.65

Tested by

no test coverage detected