Skip to content

Commit

Permalink
terror: improve test.
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood committed Nov 6, 2015
1 parent 807b897 commit f1a4be7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions terror/terror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
package terror

import (
"fmt"
"testing"

"github.com/juju/errors"
. "github.com/pingcap/check"
"strings"
)

func TestT(t *testing.T) {
Expand Down Expand Up @@ -53,12 +53,22 @@ func (s *testTErrorSuite) TestTError(c *C) {
var predefinedErr = ClassExecutor.New(ErrCode(123), "predefiend error")

func example() error {
err := call()
return errors.Trace(err)
}

func call() error {
return predefinedErr.Gen("error message:%s", "abc")
}

func (s *testTErrorSuite) TestExample(c *C) {
func (s *testTErrorSuite) TestTraceAndLocation(c *C) {
err := example()
fmt.Println(errors.ErrorStack(err))
stack := errors.ErrorStack(err)
lines := strings.Split(stack, "\n")
c.Assert(len(lines), Equals, 2)
for _, v := range lines {
c.Assert(strings.Contains(v, "terror_test.go"), IsTrue)
}
}

func (s *testTErrorSuite) TestErrorEqual(c *C) {
Expand Down

0 comments on commit f1a4be7

Please sign in to comment.