test: add postgres integration verification

This commit is contained in:
2026-07-18 16:53:47 +08:00
parent e1028c7197
commit a965af4d46
3 changed files with 40 additions and 27 deletions

View File

@@ -1,32 +1,14 @@
# React + TypeScript + Vite
# SenlinAI Web
This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.
Svelte + TypeScript web client for the project workbench.
Currently, two official plugins are available:
## Scripts
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
## React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
## Expanding the Oxlint configuration
If you are developing a production application, we recommend enabling type-aware lint rules by installing `oxlint-tsgolint` and editing `.oxlintrc.json`:
```json
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["react", "typescript", "oxc"],
"options": {
"typeAware": true
},
"rules": {
"react/rules-of-hooks": "error",
"react/only-export-components": ["warn", { "allowConstantExport": true }]
}
}
```powershell
npm run dev
npm test -- --run
npm run build
npx playwright test
```
See the [Oxlint rules documentation](https://oxc.rs/docs/guide/usage/linter/rules) for the full list of rules and categories.
The login shell lets users enter the server IP address or domain name used as the API base URL.

View File

@@ -0,0 +1,21 @@
//go:build integration
package db
import (
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestPostgresPing(t *testing.T) {
databaseURL := os.Getenv("DATABASE_URL")
require.NotEmpty(t, databaseURL, "DATABASE_URL is required for integration tests")
database, err := Open(databaseURL)
require.NoError(t, err)
sqlDB, err := database.DB()
require.NoError(t, err)
require.NoError(t, sqlDB.Ping())
}

View File

@@ -21,6 +21,16 @@ postgres://postgres:Weidong2023~!@8.137.107.29:19432/agent_dev?sslmode=disable
Do not hardcode this value into application source files. Pass it through `DATABASE_URL`.
Run:
```powershell
Set-Location backend
$env:DATABASE_URL='postgres://postgres:Weidong2023~!@8.137.107.29:19432/agent_dev?sslmode=disable'
go test -tags integration ./internal/db -run TestPostgresPing -v
```
Expected: `TestPostgresPing` passes.
## Web
The frontend is Svelte-only.