mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-21 18:37:14 +00:00
refactor(web): centralize background job cadences (#5269)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
// All centralized background-job cadences must remain valid cron specs. This is
|
||||
// the guard for the "single tuning surface" refactor: editing a cadence to an
|
||||
// invalid spec fails here instead of silently dropping a job at startup.
|
||||
//
|
||||
// NOTE: package web embeds the built frontend (//go:embed all:dist), so this
|
||||
// test compiles only after `npm run build` has populated web/dist — the normal
|
||||
// repo build flow.
|
||||
func TestJobCadencesAreValidCronSpecs(t *testing.T) {
|
||||
cadences := map[string]string{
|
||||
"cadenceXrayRunning": cadenceXrayRunning,
|
||||
"cadenceXrayRestart": cadenceXrayRestart,
|
||||
"cadenceXrayTraffic": cadenceXrayTraffic,
|
||||
"cadenceMtproto": cadenceMtproto,
|
||||
"cadenceClientIPScan": cadenceClientIPScan,
|
||||
"cadenceNodeHeartbeat": cadenceNodeHeartbeat,
|
||||
"cadenceNodeTraffic": cadenceNodeTraffic,
|
||||
"cadenceOutboundSub": cadenceOutboundSub,
|
||||
"cadenceCheckHash": cadenceCheckHash,
|
||||
"cadenceCPUAlarm": cadenceCPUAlarm,
|
||||
}
|
||||
for name, spec := range cadences {
|
||||
if _, err := cron.ParseStandard(spec); err != nil {
|
||||
t.Errorf("%s = %q is not a valid cron spec: %v", name, spec, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user