refactor backend packages and global db service
This commit is contained in:
24
backend/internal/models/postgres_integration_test.go
Normal file
24
backend/internal/models/postgres_integration_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
//go:build integration
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPostgresPing(t *testing.T) {
|
||||
dsn := os.Getenv("DATABASE_DSN")
|
||||
if dsn == "" {
|
||||
dsn = os.Getenv("DATABASE_URL")
|
||||
}
|
||||
require.NotEmpty(t, dsn, "DATABASE_DSN or DATABASE_URL is required for integration tests")
|
||||
|
||||
database, err := Open(dsn)
|
||||
require.NoError(t, err)
|
||||
sqlDB, err := database.DB()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, sqlDB.Ping())
|
||||
}
|
||||
Reference in New Issue
Block a user