Pass the state-file flush to a subscription in its options

A subscription flushed its state file through a package variable, which
the ntfy tests replaced with a no-op in their TestMain. Tests in other
packages could not reach it, so the daemon's own tests still flushed
for real.

Options.Sync now takes the flush; nil means (*os.File).Sync, as before.
The ntfy tests pass a no-op through their options and to saveState.
Behaviour is unchanged.

docs/plans/ntfy.md names the option, and its line references follow the
code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-12-01 12:08:36 -06:00
1 parent c548833656
commit 62e5ec9c66
9 files changed
+49 -49

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ func TestNoGoroutineLeakOverRealConnections(t *testing.T) {
o := Options{
Name: "home", Server: srv.URL, Topics: []string{"alerts"}, MinPriority: 1,
MaxBacklog: time.Hour, RateLimit: 1000, RateWindow: time.Minute, BypassPriority: 5,
Keepalive: 45 * time.Second, StateFile: t.TempDir() + "/ntfy-home.json",
Keepalive: 45 * time.Second, StateFile: t.TempDir() + "/ntfy-home.json", Sync: skipSync,
}
s, err := New(o)
if err != nil {