-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver_test.go
More file actions
47 lines (42 loc) · 1.17 KB
/
driver_test.go
File metadata and controls
47 lines (42 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package unixodbc
import (
"context"
"database/sql"
"github.com/ninthclowd/unixodbc/internal/odbc"
"testing"
)
func TestOpenHandles(t *testing.T) {
want := odbc.OpenHandles()
got := OpenHandles()
if got != want {
t.Fatalf("OpenHandles()=%v, want %v", got, want)
}
}
func TestSQL_Open(t *testing.T) {
db, err := sql.Open("unixodbc", "MyDSN")
if err != nil {
t.Fatalf("expected no error opening, got %v", err.Error())
}
if db.Driver() != driverInstance {
t.Fatalf("incorrect driver, got %v", db.Driver())
}
}
func TestDriver_OpenConnector(t *testing.T) {
db, err := driverInstance.OpenConnector("MyDSN")
if err != nil {
t.Fatalf("expected no error opening, got %v", err.Error())
}
if db.Driver() != driverInstance {
t.Fatalf("incorrect driver, got %v", db.Driver())
}
connector, ok := db.(*Connector)
if !ok {
t.Fatalf("incorrect connector, got %v", db)
}
if connStr, _ := connector.ConnectionString.ConnectionString(context.Background()); connStr != "MyDSN" {
t.Errorf("incorrect connection string, got %v", connStr)
}
if connector.StatementCacheSize != DefaultCacheSize {
t.Errorf("incorrect default cache size, got %v", connector.StatementCacheSize)
}
}