Skip to content

Commit 793bfa9

Browse files
committed
Use real connection.
1 parent 8cd3eb8 commit 793bfa9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

collector/exporter_test.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package collector
22

33
import (
4+
"database/sql"
45
"testing"
56

67
"github.com/prometheus/client_golang/prometheus"
@@ -9,14 +10,16 @@ import (
910
"gopkg.in/DATA-DOG/go-sqlmock.v1"
1011
)
1112

13+
const dsn = "root@/mysql"
14+
1215
func TestExporter(t *testing.T) {
1316
if testing.Short() {
1417
t.Skip("-short is passed, skipping test")
1518
}
1619

17-
db, mock, err := sqlmock.New()
20+
db, err := sql.Open("mysql", dsn)
1821
if err != nil {
19-
t.Fatalf("error opening a stub database connection: %s", err)
22+
t.Fatal(err)
2023
}
2124
defer db.Close()
2225

@@ -49,11 +52,6 @@ func TestExporter(t *testing.T) {
4952
}
5053
}
5154
})
52-
53-
// We make sure that all expectations were met.
54-
if err := mock.ExpectationsWereMet(); err != nil {
55-
t.Errorf("there were unfulfilled expectations: %s", err)
56-
}
5755
}
5856

5957
func TestGetMySQLVersion(t *testing.T) {

0 commit comments

Comments
 (0)