github.com/ali-iotechsys/cli@v20.10.0+incompatible/cli-plugins/manager/error_test.go (about)

     1  package manager
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/pkg/errors"
     8  	"gopkg.in/yaml.v2"
     9  	"gotest.tools/v3/assert"
    10  )
    11  
    12  func TestPluginError(t *testing.T) {
    13  	err := NewPluginError("new error")
    14  	assert.Error(t, err, "new error")
    15  
    16  	inner := fmt.Errorf("testing")
    17  	err = wrapAsPluginError(inner, "wrapping")
    18  	assert.Error(t, err, "wrapping: testing")
    19  	assert.Assert(t, errors.Is(err, inner))
    20  
    21  	actual, err := yaml.Marshal(err)
    22  	assert.NilError(t, err)
    23  	assert.Equal(t, "'wrapping: testing'\n", string(actual))
    24  }