github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/cli-plugins/manager/error_test.go (about) 1 package manager 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "testing" 7 8 "gotest.tools/v3/assert" 9 is "gotest.tools/v3/assert/cmp" 10 ) 11 12 func TestPluginError(t *testing.T) { 13 err := NewPluginError("new error") 14 assert.Check(t, is.Error(err, "new error")) 15 16 inner := fmt.Errorf("testing") 17 err = wrapAsPluginError(inner, "wrapping") 18 assert.Check(t, is.Error(err, "wrapping: testing")) 19 assert.Check(t, is.ErrorIs(err, inner)) 20 21 actual, err := json.Marshal(err) 22 assert.Check(t, err) 23 assert.Check(t, is.Equal(`"wrapping: testing"`, string(actual))) 24 }