frankban / quicktest

Quick helpers for testing Go applications
MIT License
529 stars 27 forks source link

display error output better #33

Closed rogpeppe closed 5 years ago

rogpeppe commented 6 years ago

Sample output:

        quicktest.go:109: 
            error:
              values are not equal
            got:
              &errgo.Err{
                  Message_: "",
                  Cause_:   &errgo.Err{
                      Message_:    "duplicate key",
                      Cause_:      nil,
                      Underlying_: nil,
                      File:        "/home/rog/src/go/pkg/mod/github.com/juju/simplekv@v0.0.0-20180621131638-ff82918775e5/kv.go",
                      Line:        20,
                  },
                  Underlying_: &errgo.Err{
                      Message_:    "",
                      Cause_:      &errgo.Err{(CYCLIC REFERENCE)},
                      Underlying_: &errgo.Err{
                          Message_:    "key test-key already exists",
                          Cause_:      &errgo.Err{(CYCLIC REFERENCE)},
                          Underlying_: nil,
                          File:        "/home/rog/src/go/pkg/mod/github.com/juju/simplekv@v0.0.0-20180621131638-ff82918775e5/kv.go",
                          Line:        80,
                      },
                      File: "/home/rog/src/go/pkg/mod/github.com/juju/simplekv@v0.0.0-20180621131638-ff82918775e5/memsimplekv/keyvalue.go",
                      Line: 62,
                  },
                  File: "/home/rog/src/go/pkg/mod/github.com/juju/simplekv@v0.0.0-20180621131638-ff82918775e5/kv.go",
                  Line: 84,
              }
            want:
              nil
            sources:
              keyvalue.go:71:
                68     defer close()
                69   
                70     err = simplekv.SetKeyOnce(ctx, kv, "test-key", []byte("test-value"), time.Time{})
                71!    c.Assert(err, qt.Equals, nil)
                72   
                73     result, err := kv.Get(ctx, "test-key")
                74     c.Assert(err, qt.Equals, nil)

That's a very long error message, and most of it isn't very useful. Perhaps consider formatting errors differently?

frankban commented 5 years ago

This has been fixed at https://github.com/frankban/quicktest/pull/35 and https://github.com/frankban/quicktest/pull/37