github.com/sandwich-go/boost@v1.3.29/xerror/array_test.go (about)

     1  package xerror
     2  
     3  import (
     4  	"errors"
     5  	. "github.com/smartystreets/goconvey/convey"
     6  	"testing"
     7  )
     8  
     9  func TestArray(t *testing.T) {
    10  	Convey("array", t, func() {
    11  		var arr Array
    12  		So(arr.Err(), ShouldBeNil)
    13  		So(arr.LastErr(), ShouldBeNil)
    14  
    15  		var e1 = errors.New("error 1")
    16  		var e2 = errors.New("error 2")
    17  		arr.Push(e1)
    18  		So(arr.Err(), ShouldNotBeNil)
    19  		So(arr.LastErr(), ShouldNotBeNil)
    20  		So(arr.LastErr(), ShouldEqual, e1)
    21  
    22  		arr.Push(e2)
    23  		So(arr.Err(), ShouldNotBeNil)
    24  		So(arr.LastErr(), ShouldNotBeNil)
    25  		So(arr.LastErr(), ShouldEqual, e2)
    26  
    27  		So(arr.WrappedErrors(), ShouldResemble, []error{e1, e2})
    28  
    29  		t.Log(arr.String())
    30  		t.Log(arr.Error())
    31  
    32  		arr.SetFormatFunc(DotFormatFunc)
    33  		t.Log(arr.Error())
    34  	})
    35  }