MCPcopy
hub / github.com/grafana/tempo / Test_NextReport

Function Test_NextReport

pkg/usagestats/reporter_test.go:212–245  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

210}
211
212func Test_NextReport(t *testing.T) {
213 fixtures := map[string]struct {
214 interval time.Duration
215 createdAt time.Time
216 now time.Time
217
218 next time.Time
219 }{
220 "createdAt aligned with interval and now": {
221 interval: 1 * time.Hour,
222 createdAt: time.Unix(0, time.Hour.Nanoseconds()),
223 now: time.Unix(0, 2*time.Hour.Nanoseconds()),
224 next: time.Unix(0, 2*time.Hour.Nanoseconds()),
225 },
226 "createdAt aligned with interval": {
227 interval: 1 * time.Hour,
228 createdAt: time.Unix(0, time.Hour.Nanoseconds()),
229 now: time.Unix(0, 2*time.Hour.Nanoseconds()+1),
230 next: time.Unix(0, 3*time.Hour.Nanoseconds()),
231 },
232 "createdAt not aligned": {
233 interval: 1 * time.Hour,
234 createdAt: time.Unix(0, time.Hour.Nanoseconds()+18*time.Minute.Nanoseconds()+20*time.Millisecond.Nanoseconds()),
235 now: time.Unix(0, 2*time.Hour.Nanoseconds()+1),
236 next: time.Unix(0, 2*time.Hour.Nanoseconds()+18*time.Minute.Nanoseconds()+20*time.Millisecond.Nanoseconds()),
237 },
238 }
239 for name, f := range fixtures {
240 t.Run(name, func(t *testing.T) {
241 next := nextReport(f.interval, f.createdAt, f.now)
242 require.Equal(t, f.next, next)
243 })
244 }
245}
246
247func TestWrongKV(t *testing.T) {
248 synctest.Test(t, func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

nextReportFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected