Skip to content

Commit

Permalink
add test for writing after closing the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Achille Roussel committed May 31, 2017
1 parent 36356f3 commit 0bc1c3d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ func TestConn(t *testing.T) {
},

{
scenario: "write a single message to kafka",
scenario: "write a single message to kafka should succeed",
function: testConnWrite,
},

{
scenario: "writing a message to a closed kafka connection should fail",
function: testConnCloseAndWrite,
},

{
scenario: "ensure the connection can seek to the first offset",
function: testConnSeekFirstOffset,
Expand Down Expand Up @@ -99,6 +104,16 @@ func testConnWrite(t *testing.T, conn *Conn) {
}
}

func testConnCloseAndWrite(t *testing.T, conn *Conn) {
conn.Close()

switch _, err := conn.Write([]byte("Hello World!")); err.(type) {
case *net.OpError:
default:
t.Error(err)
}
}

func testConnSeekFirstOffset(t *testing.T, conn *Conn) {
for i := 0; i != 10; i++ {
if _, err := conn.Write([]byte(strconv.Itoa(i))); err != nil {
Expand Down

0 comments on commit 0bc1c3d

Please sign in to comment.