feat(trace): add trace test helpers (#3108)
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/trace/tracetest"
|
||||
)
|
||||
|
||||
const mockedDatasource = "sqlmock"
|
||||
@@ -17,6 +18,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestSqlConn(t *testing.T) {
|
||||
me := tracetest.NewInMemoryExporter(t)
|
||||
mock, err := buildConn()
|
||||
assert.Nil(t, err)
|
||||
mock.ExpectExec("any")
|
||||
@@ -49,6 +51,7 @@ func TestSqlConn(t *testing.T) {
|
||||
assert.NotNil(t, badConn.Transact(func(session Session) error {
|
||||
return nil
|
||||
}))
|
||||
assert.Equal(t, 14, len(me.GetSpans()))
|
||||
}
|
||||
|
||||
func buildConn() (mock sqlmock.Sqlmock, err error) {
|
||||
|
||||
Reference in New Issue
Block a user