forked from pashagolub/pgxmock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver_test.go
49 lines (45 loc) · 1.02 KB
/
driver_test.go
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
48
49
package pgxmock
import (
"context"
"testing"
)
func TestTwoOpenConnectionsOnTheSameDSN(t *testing.T) {
mock, err := NewConn()
if err != nil {
t.Errorf("expected no error, but got: %s", err)
}
mock2, err := NewConn()
if err != nil {
t.Errorf("expected no error, but got: %s", err)
}
if mock == mock2 {
t.Errorf("expected not the same mock instance, but it is the same")
}
mock.Close(context.Background())
mock2.Close(context.Background())
}
func TestPools(t *testing.T) {
mock, err := NewPool()
if err != nil {
t.Errorf("expected no error, but got: %s", err)
}
mock2, err := NewPool()
if err != nil {
t.Errorf("expected no error, but got: %s", err)
}
if mock == mock2 {
t.Errorf("expected not the same mock instance, but it is the same")
}
mock.Close()
mock2.Close()
}
func TestAcquire(t *testing.T) {
mock, err := NewPool()
if err != nil {
t.Errorf("expected no error, but got: %s", err)
}
_, err = mock.Acquire(context.Background())
if err == nil {
t.Error("expected error, but got nil")
}
}