ca2a8c8aa7
Phase 8 (PROJECT_REVIEW_PLAN.md 8.1): 0 in MaxLogFiles/MaxLogAgeDays now means "keep everything" end to end. runner.CleanupLogs already treated <= 0 as disabled; validateConfig, the Settings form, and loadOrCreateConfig's backfill were the only things making that state unreachable. Phase 9 (1.1, rolling up 1.2, 1.3, 7.3): added Service.Config() and Service.Paths(), copying under mu, and converted every UI site that read Service state through the raw *storage.Store returned by Store() (now removed). jobs_view's pause control is now driven by refreshView reading svc.Config().Paused on every event instead of only mirroring its own tap handler, which makes it an actual consumer of SchedulerStateChanged. mainwindow's event listener is a real type switch, and events.go's doc comment no longer claims a compiler exhaustiveness check Go doesn't have. Unexported the redundant SetAutostart/AutostartStatus package functions in platform/autostart now that only the Manager methods are used outside the package. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
//go:build linux
|
|
|
|
package autostart
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.mixdep.ru/mix/gosentry/src/domain"
|
|
)
|
|
|
|
func TestLinuxAutostartStartsInTray(t *testing.T) {
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
|
|
executablePath := "/opt/Go Sentry/gosentry"
|
|
if err := setAutostart(true, true, executablePath, "/opt/Go Sentry/gosentry.png"); err != nil {
|
|
t.Fatalf("enable autostart: %v", err)
|
|
}
|
|
|
|
desktopPath, err := autostartDesktopPath()
|
|
if err != nil {
|
|
t.Fatalf("resolve desktop path: %v", err)
|
|
}
|
|
data, err := os.ReadFile(desktopPath)
|
|
if err != nil {
|
|
t.Fatalf("read desktop entry: %v", err)
|
|
}
|
|
|
|
expectedExec := "Exec=" + quoteDesktopExec(executablePath) + " " + domain.StartInTrayArgument
|
|
if !strings.Contains(string(data), expectedExec) {
|
|
t.Fatalf("desktop entry does not start in tray: %s", data)
|
|
}
|
|
}
|
|
|
|
func TestLinuxAutostartWithoutTrayFlag(t *testing.T) {
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
|
|
executablePath := "/opt/Go Sentry/gosentry"
|
|
if err := setAutostart(true, false, executablePath, ""); err != nil {
|
|
t.Fatalf("enable autostart: %v", err)
|
|
}
|
|
|
|
desktopPath, err := autostartDesktopPath()
|
|
if err != nil {
|
|
t.Fatalf("resolve desktop path: %v", err)
|
|
}
|
|
data, err := os.ReadFile(desktopPath)
|
|
if err != nil {
|
|
t.Fatalf("read desktop entry: %v", err)
|
|
}
|
|
|
|
expectedExec := "Exec=" + quoteDesktopExec(executablePath)
|
|
if !strings.Contains(string(data), expectedExec) {
|
|
t.Fatalf("desktop entry should not include tray flag: %s", data)
|
|
}
|
|
if strings.Contains(string(data), domain.StartInTrayArgument) {
|
|
t.Fatalf("desktop entry must not pass --start-in-tray: %s", data)
|
|
}
|
|
}
|
|
|