Skip to content

Commit

Permalink
server_test: wait for OnClose in TestClientEOF.
Browse files Browse the repository at this point in the history
In the test for client Call failing with ErrClosed on a closed
server, wait for the client's OnClose handler to get triggered
to make sure closing the socket had properly been administered
on the client's side. Otherwise trying a new Call() might fail
with some other error than ErrClosed, for instance ENOTCONN.

Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Jun 24, 2023
1 parent e3b6a4d commit b56a384
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,12 @@ func TestClientEOF(t *testing.T) {
server = mustServer(t)(NewServer())
addr, listener = newTestListener(t)
errs = make(chan error, 1)
client, cleanup = newTestClient(t, addr)
onCloseCh = make(chan struct{})
client, cleanup = newTestClient(t, addr,
WithOnClose(func() {
onCloseCh <- struct{}{}
}),
)
)
defer cleanup()
defer listener.Close()
Expand All @@ -363,6 +368,8 @@ func TestClientEOF(t *testing.T) {
t.Fatal(err)
}

<-onCloseCh

// server shutdown, but we still make a call.
if err := client.Call(ctx, serviceName, "Test", tp, tp); err == nil {
t.Fatalf("expected error when calling against shutdown server")
Expand Down

0 comments on commit b56a384

Please sign in to comment.