Ditch the alphabet

This commit is contained in:
David Robertson 2023-09-20 14:23:11 +01:00
parent ed7f052682
commit f264c4ff90
No known key found for this signature in database
GPG Key ID: 903ECE108A39DEDD

View File

@ -1140,16 +1140,19 @@ func TestEventTable_SelectLatestEventsBetween_MissingPrevious(t *testing.T) {
roomID := fmt.Sprintf("!%s", t.Name()) roomID := fmt.Sprintf("!%s", t.Name())
// Event IDs ending with `-gap` have MissingPrevious: true. // Event IDs ending with `-gap` have MissingPrevious: true.
events := []Event{ events := []Event{
{ID: "A", MissingPrevious: false}, {ID: "chunk1-event1", MissingPrevious: false},
{ID: "B", MissingPrevious: false}, {ID: "chunk1-event2", MissingPrevious: false},
{ID: "C", MissingPrevious: false}, {ID: "chunk1-event3", MissingPrevious: false},
{ID: "D-gap", MissingPrevious: true}, // GAP
{ID: "E", MissingPrevious: false}, {ID: "chunk2-event1", MissingPrevious: true},
{ID: "F", MissingPrevious: false}, {ID: "chunk2-event2", MissingPrevious: false},
{ID: "G-gap", MissingPrevious: true}, {ID: "chunk2-event3", MissingPrevious: false},
{ID: "H-gap", MissingPrevious: true}, // GAP
{ID: "I", MissingPrevious: false}, {ID: "chunk3-event1", MissingPrevious: true},
{ID: "J", MissingPrevious: false}, // GAP
{ID: "chunk4-event1", MissingPrevious: true},
{ID: "chunk4-event2", MissingPrevious: false},
{ID: "chunk4-event3", MissingPrevious: false},
} }
prefix := "$" + t.Name() + "-" prefix := "$" + t.Name() + "-"
for i := range events { for i := range events {
@ -1176,38 +1179,38 @@ func TestEventTable_SelectLatestEventsBetween_MissingPrevious(t *testing.T) {
{ {
Desc: "has no gaps - should omit nothing", Desc: "has no gaps - should omit nothing",
FromIDExclusive: "start", FromIDExclusive: "start",
ToIDInclusive: "C", ToIDInclusive: "chunk1-event3",
ExpectIDs: []string{"C", "B", "A"}, ExpectIDs: []string{"chunk1-event3", "chunk1-event2", "chunk1-event1"},
}, },
{ {
Desc: "ends with missing_previous - should include the end only", Desc: "ends with missing_previous - should include the end only",
FromIDExclusive: "start", FromIDExclusive: "start",
ToIDInclusive: "D-gap", ToIDInclusive: "chunk2-event1",
ExpectIDs: []string{"D-gap"}, ExpectIDs: []string{"chunk2-event1"},
}, },
{ {
Desc: "single event, ends with missing_previous - should include the end only", Desc: "single event, ends with missing_previous - should include the end only",
FromIDExclusive: "C", FromIDExclusive: "chunk1-event3",
ToIDInclusive: "D-gap", ToIDInclusive: "chunk2-event1",
ExpectIDs: []string{"D-gap"}, ExpectIDs: []string{"chunk2-event1"},
}, },
{ {
Desc: "single event, start is missing_previous - should include the end only", Desc: "single event, start is missing_previous - should include the end only",
FromIDExclusive: "D-gap", FromIDExclusive: "chunk2-event1",
ToIDInclusive: "E", ToIDInclusive: "chunk2-event2",
ExpectIDs: []string{"E"}, ExpectIDs: []string{"chunk2-event2"},
}, },
{ {
Desc: "covers two consecutive gaps - should include events from the second gap onwards.", Desc: "covers two consecutive gaps - should include events from the second gap onwards.",
FromIDExclusive: "E", FromIDExclusive: "chunk2-event2",
ToIDInclusive: "J", ToIDInclusive: "chunk4-event3",
ExpectIDs: []string{"J", "I", "H-gap"}, ExpectIDs: []string{"chunk4-event3", "chunk4-event2", "chunk4-event1"},
}, },
{ {
Desc: "covers three gaps, the latter two consecutive - should only return from the second gap onwards", Desc: "covers three gaps, the latter two consecutive - should only return from the second gap onwards",
FromIDExclusive: "B", FromIDExclusive: "chunk1-event2",
ToIDInclusive: "I", ToIDInclusive: "chunk4-event2",
ExpectIDs: []string{"I", "H-gap"}, ExpectIDs: []string{"chunk4-event2", "chunk4-event1"},
}, },
} }