...

Source file src/github.com/lestrrat-go/backoff/v2/internal_test.go

Documentation: github.com/lestrrat-go/backoff/v2

     1  package backoff
     2  
     3  import (
     4  	"math/rand"
     5  	"testing"
     6  	"time"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  func TestOptionPassing(t *testing.T) {
    12  	cOptions := []ControllerOption{
    13  		WithMaxRetries(9999999999999),
    14  	}
    15  	igOptions := []ExponentialOption{
    16  		WithJitterFactor(0.99),
    17  		WithMaxInterval(24 * time.Hour),
    18  		WithMinInterval(time.Nanosecond),
    19  		WithMultiplier(99999),
    20  		WithRNG(rand.New(rand.NewSource(time.Now().UnixNano()))),
    21  	}
    22  
    23  	merged := igOptions
    24  	for _, option := range cOptions {
    25  		merged = append(merged, option.(ExponentialOption))
    26  	}
    27  	p := NewExponentialPolicy(merged...)
    28  
    29  	if !assert.Equal(t, cOptions, p.cOptions) {
    30  		return
    31  	}
    32  	if !assert.Equal(t, igOptions, p.igOptions) {
    33  		return
    34  	}
    35  }
    36  

View as plain text