Commit 31731b27 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/rpc/jsonrpc: add temporarily-disabled failing test

To be enabled by https://golang.org/cl/71230045/

Update #7442

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/69860056
parent 3b961ba3
......@@ -5,6 +5,7 @@
package jsonrpc
import (
"bytes"
"encoding/json"
"errors"
"fmt"
......@@ -12,6 +13,7 @@ import (
"io/ioutil"
"net"
"net/rpc"
"strings"
"testing"
)
......@@ -202,6 +204,40 @@ func TestMalformedOutput(t *testing.T) {
}
}
func TestServerErrorHasNullResult(t *testing.T) {
t.Skip("Known failing test; Issue 7442")
var out bytes.Buffer
sc := NewServerCodec(struct {
io.Reader
io.Writer
io.Closer
}{
Reader: strings.NewReader(`{"method": "Arith.Add", "id": "123", "params": []}`),
Writer: &out,
Closer: ioutil.NopCloser(nil),
})
r := new(rpc.Request)
if err := sc.ReadRequestHeader(r); err != nil {
t.Fatal(err)
}
const valueText = "the value we don't want to see"
const errorText = "some error"
err := sc.WriteResponse(&rpc.Response{
ServiceMethod: "Method",
Seq: 1,
Error: errorText,
}, valueText)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(out.String(), errorText) {
t.Fatalf("Response didn't contain expected error %q: %s", errorText, &out)
}
if strings.Contains(out.String(), valueText) {
t.Errorf("Response contains both an error and value: %s", &out)
}
}
func TestUnexpectedError(t *testing.T) {
cli, srv := myPipe()
go cli.PipeWriter.CloseWithError(errors.New("unexpected error!")) // reader will get this error
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment