-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver_test.go
More file actions
46 lines (39 loc) · 807 Bytes
/
driver_test.go
File metadata and controls
46 lines (39 loc) · 807 Bytes
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
package sqlmock
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDriverOpen(t *testing.T) {
tests := []struct {
name string
dsn string
mockName string
}{
{
name: "opens_connection_with_empty_dsn",
dsn: "",
mockName: "empty-dsn",
},
{
name: "opens_connection_with_non_empty_dsn",
dsn: "ignored",
mockName: "non-empty-dsn",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Arrange
mock := NewMock()
driver := &Driver{mock: mock}
// Act
connRaw, err := driver.Open(tt.dsn)
// Assert
require.NoError(t, err)
require.NotNil(t, connRaw)
conn, ok := connRaw.(*Conn)
require.True(t, ok)
assert.Same(t, mock, conn.mock)
})
}
}