From 792b1b3a56f5de6bcccd3866f7fa53148f767a2d Mon Sep 17 00:00:00 2001 From: Rustam Gilyazov <16064414+rusq@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:04:00 +1000 Subject: [PATCH] fix tests --- internal/network/limits.go | 2 +- internal/network/network_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/network/limits.go b/internal/network/limits.go index 3abe285b..d4ad69ac 100644 --- a/internal/network/limits.go +++ b/internal/network/limits.go @@ -30,7 +30,7 @@ type TierLimit struct { // Tier limiter burst Burst uint `json:"burst,omitempty" yaml:"burst,omitempty" validate:"gte=1" toml:"burst,omitempty"` // Tier retries when getting transient errors, i.e. 429 or 500-599. - Retries int `json:"retries,omitempty" yaml:"retries,omitempty" toml:"retries,omitempty" validate:"gte=1"` + Retries int `json:"retries,omitempty" yaml:"retries,omitempty" toml:"retries,omitempty"` } // RequestLimit defines the limits on the requests that are sent to the API. diff --git a/internal/network/network_test.go b/internal/network/network_test.go index 57758b44..03fb385c 100644 --- a/internal/network/network_test.go +++ b/internal/network/network_test.go @@ -64,7 +64,7 @@ func dAbs(d time.Duration) time.Duration { return d } -func Test_withRetry(t *testing.T) { +func TestWithRetry(t *testing.T) { t.Parallel() type args struct { ctx context.Context @@ -166,6 +166,7 @@ func Test_withRetry(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() start := time.Now() if err := WithRetry(tt.args.ctx, tt.args.l, tt.args.maxAttempts, tt.args.fn); (err != nil) != tt.wantErr { t.Errorf("withRetry() error = %v, wantErr %v", err, tt.wantErr) @@ -179,6 +180,7 @@ func Test_withRetry(t *testing.T) { }) } t.Run("500 error handling", func(t *testing.T) { + t.Parallel() waitFn = func(attempt int) time.Duration { return 50 * time.Millisecond } defer func() { waitFn = cubicWait @@ -275,6 +277,7 @@ func Test_withRetry(t *testing.T) { } func Test_cubicWait(t *testing.T) { + t.Parallel() type args struct { attempt int } @@ -293,6 +296,7 @@ func Test_cubicWait(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() if got := cubicWait(tt.args.attempt); !reflect.DeepEqual(got, tt.want) { t.Errorf("waitTime() = %v, want %v", got, tt.want) } @@ -301,6 +305,7 @@ func Test_cubicWait(t *testing.T) { } func Test_isRecoverable(t *testing.T) { + t.Parallel() type args struct { statusCode int } @@ -323,6 +328,7 @@ func Test_isRecoverable(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() if got := isRecoverable(tt.args.statusCode); got != tt.want { t.Errorf("isRecoverable() = %v, want %v", got, tt.want) }