Skip to content

Commit e5d24e9

Browse files
committed
test: verify sqlite busy timeout across pooled connections
1 parent a737cf9 commit e5d24e9

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package store
2+
3+
import (
4+
"context"
5+
"testing"
6+
)
7+
8+
func TestSQLiteBusyTimeoutAppliesToEveryPooledConnection(t *testing.T) {
9+
setupTestDB(t)
10+
11+
ctx := context.Background()
12+
conns := make([]interface{ Close() error }, 0, 4)
13+
for i := 0; i < 4; i++ {
14+
conn, err := DB().Conn(ctx)
15+
if err != nil {
16+
t.Fatalf("open pooled connection %d: %v", i, err)
17+
}
18+
conns = append(conns, conn)
19+
20+
var timeout int
21+
if err := conn.QueryRowContext(ctx, `PRAGMA busy_timeout`).Scan(&timeout); err != nil {
22+
t.Fatalf("read busy_timeout on connection %d: %v", i, err)
23+
}
24+
if timeout != 30000 {
25+
t.Fatalf("connection %d busy_timeout=%d, want 30000", i, timeout)
26+
}
27+
}
28+
for _, conn := range conns {
29+
_ = conn.Close()
30+
}
31+
}

0 commit comments

Comments
 (0)