(t *testing.T)
| 17 | func (m mockEvent) CreatedAt() time.Time { return time.Unix(int64(m), 0) } |
| 18 | |
| 19 | func TestSortedEvents(t *testing.T) { |
| 20 | makeInput := func(times ...int64) chan Event { |
| 21 | out := make(chan Event) |
| 22 | go func() { |
| 23 | for _, t := range times { |
| 24 | out <- mockEvent(t) |
| 25 | } |
| 26 | close(out) |
| 27 | }() |
| 28 | return out |
| 29 | } |
| 30 | |
| 31 | sorted := SortedEvents( |
| 32 | makeInput(), |
| 33 | makeInput(1, 7, 9, 19), |
| 34 | makeInput(2, 8, 23), |
| 35 | makeInput(35, 48, 59, 64, 721), |
| 36 | ) |
| 37 | |
| 38 | var previous Event |
| 39 | for event := range sorted { |
| 40 | if previous != nil { |
| 41 | require.True(t, previous.CreatedAt().Before(event.CreatedAt())) |
| 42 | } |
| 43 | previous = event |
| 44 | } |
| 45 | } |
nothing calls this directly
no test coverage detected