graphql-engine/cli/internal/errors/errors_test.go
Aravind K P 451f252c0f cli: [rfc] improve error handling
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4817
GitOrigin-RevId: 340f8d0cb3df496c1c0df1cc60fe3752dd58c75c
2022-09-21 08:29:37 +00:00

29 lines
587 B
Go

package errors
import (
"errors"
"fmt"
"net/url"
"testing"
"github.com/stretchr/testify/assert"
)
func TestUnwrappingErrorsWithKind(t *testing.T) {
e := E("Test", KindNetwork, &url.Error{
Op: "Test URL Error",
URL: "https://test-url",
Err: fmt.Errorf("something"),
})
assert.True(t, IsKind(KindNetwork, e))
var urlErr *url.Error
assert.True(t, errors.As(e, &urlErr))
}
func TestCanGetWrappedKind(t *testing.T) {
e1 := E("E1", KindHasuraAPI, "some bad error")
e2 := E("E2", fmt.Errorf("something bad occured: %w", e1))
assert.True(t, IsKind(KindHasuraAPI, e2))
}