- Imported packages from separate repos: - github.com/Snider/config -> pkg/config - github.com/Snider/display -> pkg/display - github.com/Snider/help -> pkg/help - github.com/Snider/i18n -> pkg/i18n - github.com/Snider/updater -> pkg/updater - Moved core code from root to pkg/core - Flattened nested package structures - Updated all import paths to github.com/Snider/Core/pkg/* - Added Display interface to Core - Updated go.work for workspace modules Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
29 lines
683 B
Go
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)
|
|
}
|