mirror of https://github.com/docker/cli.git
25 lines
542 B
Go
25 lines
542 B
Go
package manager
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"testing"
|
|
|
|
"gotest.tools/v3/assert"
|
|
is "gotest.tools/v3/assert/cmp"
|
|
)
|
|
|
|
func TestPluginError(t *testing.T) {
|
|
err := NewPluginError("new error")
|
|
assert.Check(t, is.Error(err, "new error"))
|
|
|
|
inner := errors.New("testing")
|
|
err = NewPluginError("wrapping: %w", inner)
|
|
assert.Check(t, is.Error(err, "wrapping: testing"))
|
|
assert.Check(t, is.ErrorIs(err, inner))
|
|
|
|
actual, err := json.Marshal(err)
|
|
assert.Check(t, err)
|
|
assert.Check(t, is.Equal(`"wrapping: testing"`, string(actual)))
|
|
}
|