-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtx_test.go
More file actions
29 lines (25 loc) · 1010 Bytes
/
Copy pathtx_test.go
File metadata and controls
29 lines (25 loc) · 1010 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
package quackdriver
import (
"context"
"database/sql"
"database/sql/driver"
"strings"
"testing"
)
// Regression: BeginTx must reject non-default isolation levels and the
// read-only flag instead of silently dropping them. Per the database/sql
// contract, drivers signal lack of support via an error so the caller
// learns the requested semantics are not honoured.
func TestBeginTxRejectsUnsupportedOptions(t *testing.T) {
// Build a Conn without performing a real handshake — BeginTx checks
// opts before doing any network I/O.
c := &Conn{}
if _, err := c.BeginTx(context.Background(), driver.TxOptions{
Isolation: driver.IsolationLevel(sql.LevelSerializable),
}); err == nil || !strings.Contains(err.Error(), "isolation") {
t.Fatalf("Serializable should be rejected; got %v", err)
}
if _, err := c.BeginTx(context.Background(), driver.TxOptions{ReadOnly: true}); err == nil || !strings.Contains(err.Error(), "read-only") {
t.Fatalf("ReadOnly should be rejected; got %v", err)
}
}