2
0
mirror of https://github.com/soheilhy/cmux.git synced 2024-09-20 02:55:46 +08:00

Merge pull request #21 from soheilhy/devel

Use the readable indentation for error flow
This commit is contained in:
Soheil Hassas Yeganeh 2016-02-27 18:16:04 -05:00
commit 7ec7ce7ad1

View File

@ -109,23 +109,25 @@ func runTestHTTPServer(errCh chan<- error, l net.Listener) {
}
func runTestHTTP1Client(t *testing.T, addr net.Addr) {
if r, err := http.Get("http://" + addr.String()); err != nil {
r, err := http.Get("http://" + addr.String())
if err != nil {
t.Fatal(err)
} else {
}
defer func() {
if err := r.Body.Close(); err != nil {
if err = r.Body.Close(); err != nil {
t.Fatal(err)
}
}()
if b, err := ioutil.ReadAll(r.Body); err != nil {
b, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
} else {
}
if string(b) != testHTTP1Resp {
t.Fatalf("invalid response: want=%s got=%s", testHTTP1Resp, b)
}
}
}
}
type TestRPCRcvr struct{}
@ -208,9 +210,12 @@ func TestRead(t *testing.T) {
}
for i := 0; i < mult; i++ {
var b [len(payload)]byte
if n, err := muxedConn.Read(b[:]); err != nil {
n, err := muxedConn.Read(b[:])
if err != nil {
t.Error(err)
} else if e := len(b); n != e {
continue
}
if e := len(b); n != e {
t.Errorf("expected to read %d bytes, but read %d bytes", e, n)
}
}