From b39632fa6ff7d039c6123750a58257a4a98f7f29 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 11 Oct 2023 14:06:31 -0400 Subject: [PATCH] testing: fix configuration for retry tests (#18731) The retry tests in the `api` package set up a client but don't use `NewClient`, so the address never gets parsed into a `url.URL` and that's causing some test failures. --- api/retry_test.go | 54 ++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/api/retry_test.go b/api/retry_test.go index cd4215b1c..c59d3dd9a 100644 --- a/api/retry_test.go +++ b/api/retry_test.go @@ -43,18 +43,15 @@ func Test_RetryPut_multiple_calls(t *testing.T) { } server := httptest.NewServer(http.HandlerFunc(mh.Handle)) - - cm := &Client{ - httpClient: server.Client(), - config: Config{ - Address: server.URL, - retryOptions: &retryOptions{ - delayBase: 10 * time.Millisecond, - maxRetries: 10, - maxBackoffDelay: 100 * time.Millisecond, - }, + cm, err := NewClient(&Config{ + Address: server.URL, + retryOptions: &retryOptions{ + delayBase: 10 * time.Millisecond, + maxRetries: 10, + maxBackoffDelay: 100 * time.Millisecond, }, - } + }) + must.NoError(t, err) md, err := cm.retryPut(context.TODO(), "/endpoint", nil, nil, &WriteOptions{}) must.NoError(t, err) @@ -78,17 +75,14 @@ func Test_RetryPut_one_call(t *testing.T) { } server := httptest.NewServer(http.HandlerFunc(mh.Handle)) - - cm := &Client{ - httpClient: server.Client(), - config: Config{ - Address: server.URL, - retryOptions: &retryOptions{ - delayBase: 10 * time.Millisecond, - maxRetries: 1, - }, + cm, err := NewClient(&Config{ + Address: server.URL, + retryOptions: &retryOptions{ + delayBase: 10 * time.Millisecond, + maxRetries: 1, }, - } + }) + must.NoError(t, err) md, err := cm.retryPut(context.TODO(), "/endpoint/", nil, nil, &WriteOptions{}) must.Error(t, err) @@ -105,17 +99,15 @@ func Test_RetryPut_capped_base_too_big(t *testing.T) { } server := httptest.NewServer(http.HandlerFunc(mh.Handle)) - cm := &Client{ - httpClient: server.Client(), - config: Config{ - Address: server.URL, - retryOptions: &retryOptions{ - delayBase: math.MaxInt64 * time.Nanosecond, - maxRetries: 3, - maxBackoffDelay: 200 * time.Millisecond, - }, + cm, err := NewClient(&Config{ + Address: server.URL, + retryOptions: &retryOptions{ + delayBase: math.MaxInt64 * time.Nanosecond, + maxRetries: 3, + maxBackoffDelay: 200 * time.Millisecond, }, - } + }) + must.NoError(t, err) md, err := cm.retryPut(context.TODO(), "/endpoint", nil, nil, &WriteOptions{}) must.Error(t, err)