Rebase.
[official-gcc.git] / libgo / go / net / rpc / client_test.go
blobbbfc1ec3a3ec2851a97eb5b9c7ac6f601e2f9204
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package rpc
7 import (
8 "errors"
9 "testing"
12 type shutdownCodec struct {
13 responded chan int
14 closed bool
17 func (c *shutdownCodec) WriteRequest(*Request, interface{}) error { return nil }
18 func (c *shutdownCodec) ReadResponseBody(interface{}) error { return nil }
19 func (c *shutdownCodec) ReadResponseHeader(*Response) error {
20 c.responded <- 1
21 return errors.New("shutdownCodec ReadResponseHeader")
23 func (c *shutdownCodec) Close() error {
24 c.closed = true
25 return nil
28 func TestCloseCodec(t *testing.T) {
29 codec := &shutdownCodec{responded: make(chan int)}
30 client := NewClientWithCodec(codec)
31 <-codec.responded
32 client.Close()
33 if !codec.closed {
34 t.Error("client.Close did not close codec")