package main

import (
	"context"
	"os"
	"testing"

	"github.com/prometheus/client_golang/prometheus"
)

func TestPostgresIntegration(t *testing.T) {
	if testing.Short() {
		t.Skip("integration test disabled in short mode")
	}
	dsn, configured := os.LookupEnv("DATABASE_URL")
	if !configured {
		t.Skip("DATABASE_URL is not configured")
	}
	m := newMetrics(prometheus.NewRegistry())
	db, err := newPostgresStore(context.Background(), dsn, m)
	if err != nil {
		t.Fatalf("new store: %v", err)
	}
	defer db.Close()
	if err := db.Migrate(context.Background()); err != nil {
		t.Fatalf("migrate: %v", err)
	}
	if err := db.Ping(context.Background()); err != nil {
		t.Fatalf("ping: %v", err)
	}
}
