You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
872 B
Go
32 lines
872 B
Go
package postgres
|
|
|
|
// Tests for PostgreSQL config defaults and connection string generation.
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestDefaultConfig verifies default configuration values for the client.
|
|
func TestDefaultConfig(t *testing.T) {
|
|
cfg := DefaultConfig()
|
|
require.Equal(t, "localhost", cfg.Host)
|
|
require.Equal(t, 5432, cfg.Port)
|
|
}
|
|
|
|
// TestConfigDSNAndURL verifies DSN and URL formatting include expected parts.
|
|
func TestConfigDSNAndURL(t *testing.T) {
|
|
cfg := DefaultConfig()
|
|
require.Contains(t, cfg.DSN(), "host=localhost")
|
|
require.Contains(t, cfg.URL(), "postgresql://")
|
|
}
|
|
|
|
// TestHealthCheck verifies health checks delegate to Ping without error.
|
|
func TestHealthCheck(t *testing.T) {
|
|
client, err := NewClient(DefaultConfig())
|
|
require.NoError(t, err)
|
|
require.NoError(t, client.HealthCheck(context.Background()))
|
|
}
|