From 4f88718e6e2eff094aeee55f79136a2a55e7f62f Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Mon, 9 Feb 2026 17:13:15 -0800 Subject: [PATCH] client/setec: add a test for a negative PollInterval As documented, setting a negative poll interval should disable polling entirely. Add a test that verifies this works as advertised. It does as of this writing, so no other code changes are needed. --- client/setec/internal_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/client/setec/internal_test.go b/client/setec/internal_test.go index 6e32e49..a686aa0 100644 --- a/client/setec/internal_test.go +++ b/client/setec/internal_test.go @@ -75,3 +75,32 @@ func TestWatcher(t *testing.T) { // OK } } + +func TestPollDisabled(t *testing.T) { + d := setectest.NewDB(t, nil) + d.MustPut(d.Superuser, "full plate", "and packing steel") + + ts := setectest.NewServer(t, d, nil) + hs := httptest.NewServer(ts.Mux) + defer hs.Close() + + st, err := NewStore(t.Context(), StoreConfig{ + Client: Client{Server: hs.URL, DoHTTP: hs.Client().Do}, + Secrets: []string{"full plate"}, + PollInterval: -1, // disabled + }) + if err != nil { + t.Fatalf("NewStore: unexpected error: %v", err) + } + defer st.Close() + + // Polling should be disabled, which we check by examining the channel that + // ordinarily is closed when the poll goroutine exits. When polling is not + // enabled, it should be closed immediately upon construction. + select { + case <-st.done: + t.Log("Polling is correctly disabled") + default: + t.Error("Polling is unexpectedly enabled") + } +}