Skip to content

Commit

Permalink
pool: Correct some test failure paths.
Browse files Browse the repository at this point in the history
The current tests in the client message handling incorrect reference the
fields of a response message in the case the message type isn't the
expected type which would be a panic since the instance variable would
be nil in that case.

This corrects that by showing the expected and received message types
instead.
  • Loading branch information
davecgh committed Oct 5, 2023
1 parent c997341 commit 78382ba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pool/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func testClientMessageHandling(t *testing.T) {
}
resp, ok := msg.(*Response)
if !ok {
t.Fatalf("expected response with id %d, got %d", *r.ID, resp.ID)
t.Fatalf("expected response, got %T", msg)
}
if resp.ID != *r.ID {
t.Fatalf("expected response with id %d, got %d", *r.ID, resp.ID)
Expand Down Expand Up @@ -286,7 +286,7 @@ func testClientMessageHandling(t *testing.T) {
}
resp, ok = msg.(*Response)
if !ok {
t.Fatalf("expected response with id %d, got %d", *r.ID, resp.ID)
t.Fatalf("expected response, got %T", msg)
}
if resp.Error == nil {
t.Fatal("expected an invalid username authorize error response")
Expand Down Expand Up @@ -314,7 +314,7 @@ func testClientMessageHandling(t *testing.T) {
}
resp, ok = msg.(*Response)
if !ok {
t.Fatalf("expected response with id %d, got %d", *r.ID, resp.ID)
t.Fatalf("expected response, got %T", msg)
}
if resp.Error == nil {
t.Fatal("expected a rate limit error response")
Expand Down Expand Up @@ -346,7 +346,7 @@ func testClientMessageHandling(t *testing.T) {
}
resp, ok = msg.(*Response)
if !ok {
t.Fatalf("expected response with id %d, got %d", *r.ID, resp.ID)
t.Fatalf("expected response, got %T", msg)
}
if resp.ID != *r.ID {
t.Fatalf("expected response with id %d, got %d", *r.ID, resp.ID)
Expand Down

0 comments on commit 78382ba

Please sign in to comment.