go/e_test.go
Snider 003996b148 refactor: Flatten repository structure (#28)
- Move Go files from core, e, and runtime directories to the project root.
- Unify package declarations to a single 'core' package.
- Update go.work to exclude the cmd directory from the main build.
- Resolve naming conflicts and update import paths.
- Fix tests to work with the new structure.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-11-13 18:47:46 +00:00

29 lines
683 B
Go

package core
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestE_Good(t *testing.T) {
err := E("test.op", "test message", assert.AnError)
assert.Error(t, err)
assert.Equal(t, "test.op: test message: assert.AnError general error for testing", err.Error())
err = E("test.op", "test message", nil)
assert.Error(t, err)
assert.Equal(t, "test.op: test message", err.Error())
}
func TestE_Unwrap(t *testing.T) {
originalErr := errors.New("original error")
err := E("test.op", "test message", originalErr)
assert.True(t, errors.Is(err, originalErr))
var eErr *Error
assert.True(t, errors.As(err, &eErr))
assert.Equal(t, "test.op", eErr.Op)
}