Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package db
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestParsePoolConfigDefaults(t *testing.T) {
|
|
opts := DefaultPoolOptions()
|
|
cfg, err := ParsePoolConfig("postgres://descrybe:descrybe@localhost:5433/descrybe?sslmode=disable", opts)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg.MaxConns != 20 || cfg.MinConns != 2 {
|
|
t.Fatalf("size max=%d min=%d", cfg.MaxConns, cfg.MinConns)
|
|
}
|
|
if cfg.MaxConnLifetime != time.Hour {
|
|
t.Fatalf("lifetime %v", cfg.MaxConnLifetime)
|
|
}
|
|
if cfg.MaxConnLifetimeJitter != 6*time.Minute {
|
|
t.Fatalf("lifetime jitter %v", cfg.MaxConnLifetimeJitter)
|
|
}
|
|
if cfg.MaxConnIdleTime != 5*time.Minute {
|
|
t.Fatalf("idle %v", cfg.MaxConnIdleTime)
|
|
}
|
|
if cfg.HealthCheckPeriod != time.Minute {
|
|
t.Fatalf("health %v", cfg.HealthCheckPeriod)
|
|
}
|
|
got := cfg.ConnConfig.RuntimeParams["statement_timeout"]
|
|
if got != "30000" {
|
|
t.Fatalf("statement_timeout=%q want 30000ms", got)
|
|
}
|
|
}
|
|
|
|
func TestParsePoolConfigDisablesStatementTimeout(t *testing.T) {
|
|
opts := DefaultPoolOptions()
|
|
opts.StatementTimeout = 0
|
|
cfg, err := ParsePoolConfig("postgres://descrybe:descrybe@localhost:5433/descrybe?sslmode=disable", opts)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, ok := cfg.ConnConfig.RuntimeParams["statement_timeout"]; ok {
|
|
t.Fatal("expected statement_timeout unset when duration is 0")
|
|
}
|
|
}
|