1
0
mirror of https://github.com/golang/go synced 2024-11-23 08:20:05 -07:00

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
This commit is contained in:
Brad Fitzpatrick 2014-03-05 16:01:37 -08:00
parent 3b961ba3d2
commit 31731b27cd

View File

@ -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