(t *testing.T)
| 210 | } |
| 211 | |
| 212 | func 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 | } |
nothing calls this directly
no test coverage detected