3x-ui/internal/web/controller
MHSanaei 12d51d7195 perf(tests): copy a migrated template DB instead of migrating per test
Most tests opened a throwaway panel DB with database.InitDB, which runs the
full AutoMigrate + seed on an empty file every time: ~230ms, and ~850ms under
-race because GORM's reflection-heavy migration is what the detector slows
most. internal/web/service does this in ~550 of its 830 tests, so the CI race
job spent ~10 of its ~14.6 minutes re-migrating empty databases.

internal/database/dbtest.InitDB migrates once per test process, then hands
each test its own copy of that file (~130ms under -race) and registers the
CloseDB cleanup. The copy then goes through InitDB like a panel restart, so
every test still starts from the state a fresh install has. Tests that reopen
an existing file, migrate a hand-built legacy DB or target Postgres keep
calling database.InitDB.

Locally under -race: internal/web/service 626s (last CI run) -> 114s,
internal/sub 246s -> 35s.
2026-09-27 03:04:50 +02:00
..
api.go fix(api): return 401 for invalid Bearer token instead of 404 (#6459) 2026-09-12 11:52:15 +02:00
api_auth_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00
base.go
client.go feat(clients): preserve traffic counters in portable export/import (#6469) 2026-09-27 02:48:40 +02:00
client_happ_test.go feat(happ): generate Crypt5 subscription links locally (#6494) 2026-09-13 12:44:55 +02:00
client_partial_apply_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00
client_renewal_preview_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00
dist.go feat(web): add network-only PWA installability (#6190) 2026-08-18 15:33:20 +02:00
dist_test.go feat(web): add network-only PWA installability (#6190) 2026-08-18 15:33:20 +02:00
geodata_test.go
group.go
host.go
host_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00
import_db_restart_test.go fix(web): restart panel after ImportDB so subPath routes match (#6446) (#6456) 2026-09-13 21:39:15 +02:00
inbound.go fix(sub): never use X-Real-IP as the subscription host (#6608) 2026-09-26 21:13:46 +02:00
inbound_node_sync_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00
index.go feat(panel): add sponsor slots fed from sponsors.sanaei.dev 2026-09-26 03:31:51 +02:00
login_limiter.go
login_limiter_test.go
node.go
node_credentials_writeonly_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00
panel_update_test.go
pwa.go feat(web): add network-only PWA installability (#6190) 2026-08-18 15:33:20 +02:00
pwa_test.go feat(web): add network-only PWA installability (#6190) 2026-08-18 15:33:20 +02:00
server.go fix(nodes): stop a restarting panel from reporting itself as down 2026-09-18 13:25:24 +03:00
setting.go feat(discord): add Discord notification bot service (#6486) 2026-09-13 14:04:53 +02:00
setting_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00
spa.go
spa_test.go
sub_balancer.go feat(sub): leastLoad member weights for subscription balancers (#6304) 2026-09-02 20:21:27 +02:00
sub_balancer_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00
util.go
util_test.go fix(sub): never use X-Real-IP as the subscription host (#6608) 2026-09-26 21:13:46 +02:00
websocket.go
xray_setting.go feat(geodata): add standard source presets (#6504) 2026-09-13 20:02:43 +02:00
xray_setting_warp_test.go perf(tests): copy a migrated template DB instead of migrating per test 2026-09-27 03:04:50 +02:00