Add unwrap tests for normal and stone errors
All checks were successful
Go CI/CD / go-ci (push) Successful in 10m43s
Go CI/CD / go-ci (pull_request) Successful in 10m7s

Introduce tests to validate the behavior of the Unwrap function for both standard errors and StoneError instances. Ensure correct handling of wrapped errors and verify type identification with IsStoneError checks.
This commit is contained in:
Rene Nochebuena 2025-04-12 17:53:48 -06:00
parent 24ea252c96
commit bcb4a3008d
Signed by: Rene Nochebuena
GPG Key ID: A9FD83117EA538D8

View File

@ -33,6 +33,32 @@ func Test_StoneWrap(t *testing.T) {
t.Log(stoneError)
}
func Test_NormalUnwrap(t *testing.T) {
normalError := errors.New("test")
stoneError := Wrap(normalError, 1, "test")
unwrap := stoneError.Unwrap()
if IsStoneError(unwrap) {
t.Fail()
} else {
t.Log(stoneError)
}
}
func Test_StoneUnwrap(t *testing.T) {
normalError := New(1, "test")
stoneError := Wrap(normalError, 1, "test")
unwrap := stoneError.Unwrap()
if !IsStoneError(unwrap) {
t.Fail()
} else {
t.Log(stoneError)
}
}
func Test_ToJSON(t *testing.T) {
stoneError := New(1, "test").
WithMetadata("key", "value").