mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-07 20:08:17 +02:00
add retry package
This commit is contained in:
parent
5568606f03
commit
2c7955b27d
5 changed files with 416 additions and 0 deletions
29
internal/retry/error_test.go
Normal file
29
internal/retry/error_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package retry_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/retry"
|
||||
)
|
||||
|
||||
type testError string
|
||||
|
||||
func (e testError) Error() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e testError) IsTerminal() {}
|
||||
|
||||
func TestError(t *testing.T) {
|
||||
t.Run("local terminal error", func(t *testing.T) {
|
||||
err := fmt.Errorf("wrap: %w", retry.NewTerminalError(fmt.Errorf("inner")))
|
||||
require.True(t, retry.IsTerminalError(err))
|
||||
})
|
||||
t.Run("external terminal error", func(t *testing.T) {
|
||||
err := fmt.Errorf("wrap: %w", testError("inner"))
|
||||
require.True(t, retry.IsTerminalError(err))
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue