2018-12-19 09:49:20 -05:00
|
|
|
package manager
|
|
|
|
|
|
|
|
import (
|
2022-11-16 16:08:09 -05:00
|
|
|
"encoding/json"
|
2018-12-19 09:49:20 -05:00
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2020-02-22 12:12:14 -05:00
|
|
|
"gotest.tools/v3/assert"
|
2022-11-16 16:08:09 -05:00
|
|
|
is "gotest.tools/v3/assert/cmp"
|
2018-12-19 09:49:20 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestPluginError(t *testing.T) {
|
|
|
|
err := NewPluginError("new error")
|
2022-11-16 16:08:09 -05:00
|
|
|
assert.Check(t, is.Error(err, "new error"))
|
2018-12-19 09:49:20 -05:00
|
|
|
|
|
|
|
inner := fmt.Errorf("testing")
|
|
|
|
err = wrapAsPluginError(inner, "wrapping")
|
2022-11-16 16:08:09 -05:00
|
|
|
assert.Check(t, is.Error(err, "wrapping: testing"))
|
|
|
|
assert.Check(t, is.ErrorIs(err, inner))
|
2018-12-19 09:49:20 -05:00
|
|
|
|
2022-11-16 16:08:09 -05:00
|
|
|
actual, err := json.Marshal(err)
|
|
|
|
assert.Check(t, err)
|
|
|
|
assert.Check(t, is.Equal(`"wrapping: testing"`, string(actual)))
|
2018-12-19 09:49:20 -05:00
|
|
|
}
|