Skip to content

Commit b4b35b1

Browse files
committed
[+] add TestCopyErrors test case
1 parent 8188c59 commit b4b35b1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/pgengine/copy_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"testing"
77

8+
"github.com/cybertec-postgresql/pg_timetable/internal/pgengine"
89
"github.com/stretchr/testify/assert"
910
)
1011

@@ -34,3 +35,13 @@ func TestCopyToFile(t *testing.T) {
3435
assert.True(t, cnt == 5, "Should copy exactly 5 rows")
3536
assert.NoError(t, os.RemoveAll("test.csv"), "Test output should be removed")
3637
}
38+
39+
func TestCopyErrors(t *testing.T) {
40+
initmockdb(t)
41+
pge := pgengine.NewDB(mockPool, "pgengine_unit_test")
42+
defer mockPool.Close()
43+
_, err := pge.CopyFromFile(context.Background(), "foo", "boo")
44+
assert.Error(t, err, "Should fail in pgxmock Acquire()")
45+
_, err = pge.CopyToFile(context.Background(), "foo", "boo")
46+
assert.Error(t, err, "Should fail in pgxmock Acquire()")
47+
}

0 commit comments

Comments
 (0)