MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / TestUsagePusher_RunCancelExits

Function TestUsagePusher_RunCancelExits

internal/nodeagent/usage_test.go:212–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

210}
211
212func TestUsagePusher_RunCancelExits(t *testing.T) {
213 t.Parallel()
214 api := &mockUsageAPI{}
215 p := NewUsagePusher(api, 10*time.Millisecond)
216 ctx, cancel := context.WithCancel(context.Background())
217 done := make(chan error, 1)
218 go func() { done <- p.Run(ctx) }()
219 time.Sleep(30 * time.Millisecond)
220 cancel()
221 select {
222 case err := <-done:
223 if !errors.Is(err, context.Canceled) {
224 t.Fatalf("Run err = %v, want Canceled", err)
225 }
226 case <-time.After(time.Second):
227 t.Fatalf("Run did not return on cancel")
228 }
229}

Callers

nothing calls this directly

Calls 2

RunMethod · 0.95
NewUsagePusherFunction · 0.85

Tested by

no test coverage detected