Files
go-core/dbpool/postgres_test.go
2026-03-01 03:04:10 +01:00

27 lines
704 B
Go

package dbpool
import (
"context"
"strings"
"testing"
"time"
)
func TestNewPostgresPool_ParseConfigError(t *testing.T) {
_, err := NewPostgresPool(context.Background(), "://invalid-url", PoolConfig{})
if err == nil || !strings.Contains(err.Error(), "parse postgres pool config") {
t.Fatalf("expected parse config error, got %v", err)
}
}
func TestNewPostgresPool_PingError(t *testing.T) {
_, err := NewPostgresPool(
context.Background(),
"postgres://postgres:postgres@127.0.0.1:1/appdb?sslmode=disable",
PoolConfig{ConnectionAcquireWait: 20 * time.Millisecond},
)
if err == nil || !strings.Contains(err.Error(), "ping postgres") {
t.Fatalf("expected ping error, got %v", err)
}
}