feat: mysql and redis metric support (#2355)

* feat: mysql and redis metric support

* feat: mysql and redis metric support

* feat: mysql and redis metric support

Co-authored-by: dawn.zhou <dawn.zhou@yijinin.com>
This commit is contained in:
dawn_zhou
2022-09-17 19:35:30 +08:00
committed by GitHub
parent b8664be2bb
commit ae7f1aabdd
15 changed files with 164 additions and 23 deletions

View File

@@ -17,7 +17,8 @@ func init() {
}
func TestSqlConn(t *testing.T) {
mock := buildConn()
mock, err := buildConn()
assert.Nil(t, err)
mock.ExpectExec("any")
mock.ExpectQuery("any").WillReturnRows(sqlmock.NewRows([]string{"foo"}))
conn := NewMysql(mockedDatasource)
@@ -50,8 +51,8 @@ func TestSqlConn(t *testing.T) {
}))
}
func buildConn() (mock sqlmock.Sqlmock) {
connManager.GetResource(mockedDatasource, func() (io.Closer, error) {
func buildConn() (mock sqlmock.Sqlmock, err error) {
_, err = connManager.GetResource(mockedDatasource, func() (io.Closer, error) {
var db *sql.DB
var err error
db, mock, err = sqlmock.New()