コード例 #1
0
ファイル: client_test.go プロジェクト: scabwort/protorpc
func TestCloseCodec(t *testing.T) {
	codec := &shutdownCodec{responded: make(chan int)}
	client := protorpc.NewClientWithCodec(codec)
	<-codec.responded
	client.Close()
	if !codec.closed {
		t.Error("client.Close did not close codec")
	}
}
コード例 #2
0
ファイル: server_test.go プロジェクト: scabwort/protorpc
func TestSendDeadlock(t *testing.T) {
	client := protorpc.NewClientWithCodec(WriteFailCodec(0))
	defer client.Close()

	done := make(chan bool)
	go func() {
		testSendDeadlock(client)
		testSendDeadlock(client)
		done <- true
	}()
	select {
	case <-done:
		return
	case <-time.After(5 * time.Second):
		t.Fatal("deadlock")
	}
}