Skip to content

Commit

Permalink
test: replace panic with returning error (#1747)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Apr 2, 2024
1 parent e28be0c commit 1c3ba3b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2003,9 +2003,8 @@ func TestClientNonIdempotentRetry(t *testing.T) {
s: "HTTP/1.1 345 OK\r\nContent-Type: foobar\r\nContent-Length: 7\r\n\r\n0123456",
}, nil
default:
t.Fatalf("unexpected number of dials: %d", dialsCount)
return nil, fmt.Errorf("unexpected number of dials: %d", dialsCount)
}
panic("unreachable")
},
}

Expand Down Expand Up @@ -2053,9 +2052,8 @@ func TestClientNonIdempotentRetry_BodyStream(t *testing.T) {
b: []byte("HTTP/1.1 345 OK\r\nContent-Type: foobar\r\n\r\n"),
}, nil
default:
t.Fatalf("unexpected number of dials: %d", dialsCount)
return nil, fmt.Errorf("unexpected number of dials: %d", dialsCount)
}
panic("unreachable")
},
}

Expand Down Expand Up @@ -2096,9 +2094,8 @@ func TestClientIdempotentRequest(t *testing.T) {
s: "HTTP/1.1 345 OK\r\nContent-Type: foobar\r\nContent-Length: 7\r\n\r\n0123456",
}, nil
default:
t.Fatalf("unexpected number of dials: %d", dialsCount)
return nil, fmt.Errorf("unexpected number of dials: %d", dialsCount)
}
panic("unreachable")
},
}

Expand Down Expand Up @@ -2152,9 +2149,8 @@ func TestClientRetryRequestWithCustomDecider(t *testing.T) {
s: "HTTP/1.1 345 OK\r\nContent-Type: foobar\r\nContent-Length: 7\r\n\r\n0123456",
}, nil
default:
t.Fatalf("unexpected number of dials: %d", dialsCount)
return nil, fmt.Errorf("unexpected number of dials: %d", dialsCount)
}
panic("unreachable")
},
RetryIf: func(req *Request) bool {
return req.URI().String() == "http://foobar/a/b"
Expand Down

0 comments on commit 1c3ba3b

Please sign in to comment.