From bcb4a3008d470599f25b578148d381015826d558 Mon Sep 17 00:00:00 2001 From: Rene Nochebuena Date: Sat, 12 Apr 2025 17:53:48 -0600 Subject: [PATCH] Add unwrap tests for normal and stone errors 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. --- error_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/error_test.go b/error_test.go index 755e386..65f9d7f 100644 --- a/error_test.go +++ b/error_test.go @@ -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").