Refactor domain error to use errorId (#790)

* Refactor domain error to use errorId

* Wrap accepts options and uses New internally
This commit is contained in:
Louis Ruch authored and GitHub committed 2020-11-17 18:54:23 -08:00
1 parent b8a5b9adf1
commit d30dd0ff64
8 files changed
+184 -103

No files matched your search

+4 -15
View File
@@ -1,6 +1,7 @@
package errors
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
@@ -31,21 +32,9 @@ func Test_getOpts(t *testing.T) {
assert.Equal(opts, testOpts)
// try setting it
opts = GetOpts(WithWrap(ErrInvalidParameter))
testOpts.withErrWrapped = ErrInvalidParameter
assert.Equal(opts, testOpts)
})
t.Run("WithOp", func(t *testing.T) {
assert := assert.New(t)
// test default
opts := GetOpts()
testOpts := getDefaultOptions()
testOpts.withOp = ""
assert.Equal(opts, testOpts)
// try setting it
opts = GetOpts(WithOp("alice.bob"))
testOpts.withOp = "alice.bob"
err := fmt.Errorf("test error")
opts = GetOpts(WithWrap(err))
testOpts.withErrWrapped = err
assert.Equal(opts, testOpts)
})
}