func (root *Root) testCall(c *C, conn *rpc.Conn, narg, nret int, retErr, testErr bool) { root.calls = nil root.returnErr = testErr e := "" if retErr { e = "e" } method := fmt.Sprintf("Call%dr%d%s", narg, nret, e) c.Logf("test call %s", method) var r stringVal err := conn.Call("SimpleMethods", "a99", method, stringVal{"arg"}, &r) root.mu.Lock() defer root.mu.Unlock() expectCall := callInfo{ rcvr: root.simple["a99"], method: method, } if narg > 0 { expectCall.arg = stringVal{"arg"} } c.Assert(root.calls, HasLen, 1) c.Assert(*root.calls[0], Equals, expectCall) switch { case retErr && testErr: c.Assert(err, DeepEquals, &rpc.RequestError{ Message: fmt.Sprintf("error calling %s", method), }) c.Assert(r, Equals, stringVal{}) case nret > 0: c.Assert(r, Equals, stringVal{method + " ret"}) } }
func closeClient(c *C, client *rpc.Conn, srvDone <-chan error) { client.Close() err := chanReadError(c, srvDone, "server done") c.Assert(err, IsNil) }