MCPcopy Index your code
hub / github.com/git-bug/git-bug / TestSortedEvents

Function TestSortedEvents

bridge/gitlab/event_test.go:19–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17func (m mockEvent) CreatedAt() time.Time { return time.Unix(int64(m), 0) }
18
19func 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}

Callers

nothing calls this directly

Calls 4

CreatedAtMethod · 0.95
mockEventTypeAlias · 0.85
closeFunction · 0.85
SortedEventsFunction · 0.85

Tested by

no test coverage detected