Skip to content

Commit

Permalink
add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Sep 5, 2016
1 parent a17af71 commit f4d95a8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ func TestCloseThenOpen(t *testing.T) {
}
}

func TestStreamDoubleClose(t *testing.T) {
cli, err := net.Dial("tcp", "127.0.0.1:19999")
if err != nil {
t.Fatal(err)
}
session, _ := Client(cli, nil)
stream, _ := session.OpenStream()
stream.Close()
if err := stream.Close(); err == nil {
t.Log("double close doesn't return error")
}
session.Close()
}

func TestTinyReadBuffer(t *testing.T) {
cli, err := net.Dial("tcp", "127.0.0.1:19999")
if err != nil {
Expand Down Expand Up @@ -334,8 +348,21 @@ func TestReadStreamAfterSessionClose(t *testing.T) {
if _, err := stream.Read(buf); err != nil {
t.Log(err)
} else {
t.Fatal("read stream after session close succeeded")
}
}

func TestWriteStreamAfterConnectionClose(t *testing.T) {
cli, err := net.Dial("tcp", "127.0.0.1:19999")
if err != nil {
t.Fatal(err)
}
session, _ := Client(cli, nil)
stream, _ := session.OpenStream()
session.conn.Close()
if _, err := stream.Write([]byte("write after connection close")); err == nil {
t.Fatal("write after connection close failed")
}
}

func TestNumStreamAfterClose(t *testing.T) {
Expand Down

0 comments on commit f4d95a8

Please sign in to comment.