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