Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions client/setec/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}