mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-05-13 21:56:39 +02:00
Tests for driver DSN
This commit is contained in:
parent
600aa16d3e
commit
2a46c55287
@ -75,6 +75,9 @@ func TestTwoOpenConnectionsOnTheSameDSN(t *testing.T) {
|
|||||||
t.Errorf("expected no error, but got: %s", err)
|
t.Errorf("expected no error, but got: %s", err)
|
||||||
}
|
}
|
||||||
db2, mock2, err := New()
|
db2, mock2, err := New()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("expected no error, but got: %s", err)
|
||||||
|
}
|
||||||
if len(pool.conns) != 2 {
|
if len(pool.conns) != 2 {
|
||||||
t.Errorf("expected 2 connection in pool, but there is: %d", len(pool.conns))
|
t.Errorf("expected 2 connection in pool, but there is: %d", len(pool.conns))
|
||||||
}
|
}
|
||||||
@ -86,3 +89,24 @@ func TestTwoOpenConnectionsOnTheSameDSN(t *testing.T) {
|
|||||||
t.Errorf("expected not the same mock instance, but it is the same")
|
t.Errorf("expected not the same mock instance, but it is the same")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWrongDSN(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
db, _, _ := New()
|
||||||
|
defer db.Close()
|
||||||
|
if _, err := db.Driver().Open("wrong_dsn"); err == nil {
|
||||||
|
t.Error("expected error on Open")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewDSN(t *testing.T) {
|
||||||
|
if _, _, err := NewWithDSN("sqlmock_db_99"); err != nil {
|
||||||
|
t.Errorf("expected no error on NewWithDSN, but got: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDuplicateNewDSN(t *testing.T) {
|
||||||
|
if _, _, err := NewWithDSN("sqlmock_db_1"); err == nil {
|
||||||
|
t.Error("expected error on NewWithDSN")
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user