add core lib

This commit is contained in:
2026-03-01 03:04:10 +01:00
parent 9a6818ea3c
commit baa764befd
22 changed files with 2353 additions and 0 deletions

26
dbpool/postgres_test.go Normal file
View File

@@ -0,0 +1,26 @@
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)
}
}