test: add postgres integration verification
This commit is contained in:
@@ -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)
|
```powershell
|
||||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
npm run dev
|
||||||
|
npm test -- --run
|
||||||
## React Compiler
|
npm run build
|
||||||
|
npx playwright test
|
||||||
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 }]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
||||||
|
|||||||
21
backend/internal/db/postgres_integration_test.go
Normal file
21
backend/internal/db/postgres_integration_test.go
Normal 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())
|
||||||
|
}
|
||||||
@@ -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`.
|
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
|
## Web
|
||||||
|
|
||||||
The frontend is Svelte-only.
|
The frontend is Svelte-only.
|
||||||
|
|||||||
Reference in New Issue
Block a user