add core lib
This commit is contained in:
26
dbpool/postgres_test.go
Normal file
26
dbpool/postgres_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user