xray_restart_test.go 747 B

1234567891011121314151617181920212223
  1. package service
  2. import (
  3. "testing"
  4. )
  5. // A background (non-forced) restart — the pending-config-change cron, warp/ldap/
  6. // outbound reconcile jobs — must not revive an Xray the admin deliberately
  7. // stopped. Only an explicit forced restart clears the manual-stop state.
  8. func TestRestartXrayRespectsManualStop(t *testing.T) {
  9. setupSettingTestDB(t)
  10. if err := (&SettingService{}).saveSetting("xrayTemplateConfig", "{ not valid json"); err != nil {
  11. t.Fatalf("seed template: %v", err)
  12. }
  13. t.Cleanup(func() { isManuallyStopped.Store(false) })
  14. isManuallyStopped.Store(true)
  15. _ = (&XrayService{}).RestartXray(false)
  16. if !isManuallyStopped.Load() {
  17. t.Fatal("a non-forced restart cleared a deliberate manual stop and would revive xray")
  18. }
  19. }