2018-12-19 09:49:20 -05:00
|
|
|
package manager
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"gopkg.in/yaml.v2"
|
2020-02-22 12:12:14 -05:00
|
|
|
"gotest.tools/v3/assert"
|
2018-12-19 09:49:20 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestPluginError(t *testing.T) {
|
|
|
|
err := NewPluginError("new error")
|
|
|
|
assert.Error(t, err, "new error")
|
|
|
|
|
|
|
|
inner := fmt.Errorf("testing")
|
|
|
|
err = wrapAsPluginError(inner, "wrapping")
|
|
|
|
assert.Error(t, err, "wrapping: testing")
|
2020-05-09 15:28:48 -04:00
|
|
|
assert.Assert(t, errors.Is(err, inner))
|
2018-12-19 09:49:20 -05:00
|
|
|
|
|
|
|
actual, err := yaml.Marshal(err)
|
|
|
|
assert.NilError(t, err)
|
|
|
|
assert.Equal(t, "'wrapping: testing'\n", string(actual))
|
|
|
|
}
|