mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 03:11:01 -06:00
f4a5f91496
Previously every DB operation would wait 10ms before even trying. Now we try first, and defer creating the ticker until we need it.
21 lines
366 B
Go
21 lines
366 B
Go
package retryer
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMaxRetries(t *testing.T) {
|
|
retryVal := 0
|
|
|
|
err := Retry(func() (RetrySignal, error) {
|
|
retryVal++
|
|
return FuncFailure, nil
|
|
}, 8, 100*time.Millisecond, 100*time.Millisecond)
|
|
assert.Error(t, err) // Exceeding max-retries is an error.
|
|
|
|
assert.Equal(t, 8, retryVal)
|
|
}
|