Home / File/ exponential_backoff_test.go — fiber Source File

exponential_backoff_test.go — fiber Source File

Architecture documentation for exponential_backoff_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberCore Context 1 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  06704709_6b3e_c36a_84b3_c50264ae004e["exponential_backoff_test.go"]
  86295193_b3d6_5771_ebab_205c899f2f71["rand"]
  06704709_6b3e_c36a_84b3_c50264ae004e --> 86295193_b3d6_5771_ebab_205c899f2f71
  style 06704709_6b3e_c36a_84b3_c50264ae004e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package retry

import (
	"crypto/rand"
	"errors"
	"testing"
	"time"

	"github.com/stretchr/testify/require"
)

func Test_ExponentialBackoff_Retry(t *testing.T) {
	t.Parallel()
	tests := []struct {
		expErr     error
		expBackoff *ExponentialBackoff
		f          func() error
		name       string
	}{
		{
			name:       "With default values - successful",
			expBackoff: NewExponentialBackoff(),
			f: func() error {
				return nil
			},
		},
		{
			name: "Successful function",
			expBackoff: &ExponentialBackoff{
				InitialInterval: 1 * time.Millisecond,
				MaxBackoffTime:  100 * time.Millisecond,
				Multiplier:      2.0,
				MaxRetryCount:   5,
			},
			f: func() error {
				return nil
			},
		},
		{
			name: "Unsuccessful function",
			expBackoff: &ExponentialBackoff{
				InitialInterval: 2 * time.Millisecond,
				MaxBackoffTime:  100 * time.Millisecond,
				Multiplier:      2.0,
				MaxRetryCount:   5,
			},
			f: func() error {
				return errors.New("failed function")
			},
			expErr: errors.New("failed function"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			t.Parallel()
			err := tt.expBackoff.Retry(tt.f)
			require.Equal(t, tt.expErr, err)
		})
	}
// ... (111 more lines)

Domain

Subdomains

Dependencies

  • rand

Frequently Asked Questions

What does exponential_backoff_test.go do?
exponential_backoff_test.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Context subdomain.
What functions are defined in exponential_backoff_test.go?
exponential_backoff_test.go defines 4 function(s): Test_ExponentialBackoff_Next, Test_ExponentialBackoff_NextRandFailure, Test_ExponentialBackoff_Retry, Test_ExponentialBackoff_Retry_NoSleepAfterLastAttempt.
What does exponential_backoff_test.go depend on?
exponential_backoff_test.go imports 1 module(s): rand.
Where is exponential_backoff_test.go in the architecture?
exponential_backoff_test.go is located at addon/retry/exponential_backoff_test.go (domain: FiberCore, subdomain: Context, directory: addon/retry).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free