github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/error/temporary_error_test.go (about) 1 package error 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestTemporaryError(t *testing.T) { 11 // given 12 err1 := fmt.Errorf("some error: %s", "argErr") 13 err2 := fmt.Errorf("some error: %s", "argErr") 14 err3 := NewTemporaryError("some error: %s", fmt.Errorf("argErr")) 15 16 // when 17 e1 := fmt.Errorf("wrap err %s: %w", "arg1", err1) 18 e2 := AsTemporaryError(err2, "wrap err %s", "arg1") 19 e3 := fmt.Errorf("wrap err %s: %w", "arg1", err3) 20 21 // then 22 assert.False(t, IsTemporaryError(e1)) 23 assert.True(t, IsTemporaryError(e2)) 24 assert.True(t, IsTemporaryError(e3)) 25 26 assert.Equal(t, "wrap err arg1: some error: argErr", e1.Error()) 27 assert.Equal(t, "wrap err arg1: some error: argErr", e2.Error()) 28 assert.Equal(t, "wrap err arg1: some error: argErr", e3.Error()) 29 }