Test the newest merge's order, a second reopening's gaps and sub-second merge times (hq issues 348, 349)
The review of PR 179 found four paths no test held: which of two earlier plans NewestMergeOf takes, a tie between them, gaps kept across a second reopening in one keeper, and a merge time's fraction of a second.
This commit is contained in:
@@ -171,3 +171,24 @@ func TestTheBranchOrderIsTheMerges(t *testing.T) {
|
||||
t.Fatal("merges within one second lost their order")
|
||||
}
|
||||
}
|
||||
|
||||
// A merge time with a fraction of a second is kept whole in its plan, and two merges within one second keep
|
||||
// their order through the plans and the lookup (review of PR 179).
|
||||
func TestAMergeTimeKeepsItsFractionOfASecond(t *testing.T) {
|
||||
at := "2026-10-09T10:57:52.123456789Z"
|
||||
p := planOfMerge(link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main", Commit: "c1", MergedAt: at}, nil, nil)
|
||||
want := time.Date(2026, 10, 9, 10, 57, 52, 123456789, time.UTC)
|
||||
if !p.Merged.Equal(want) {
|
||||
t.Fatalf("the plan's merge time is %s, not %s", p.Merged, want)
|
||||
}
|
||||
earlier := planOfMerge(link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main", Commit: "c0",
|
||||
MergedAt: "2026-10-09T10:57:52.123456788Z"}, nil, nil)
|
||||
earlier.Created = p.Created.Add(time.Second) // made after, merged before
|
||||
if !earlierOnTheBranch(earlier, p) || earlierOnTheBranch(p, earlier) {
|
||||
t.Fatal("two merges a nanosecond apart lost their order")
|
||||
}
|
||||
m := link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main", Commit: "c0", MergedAt: "2026-10-09T10:57:52.123456788Z"}
|
||||
if !laterOnTheBranch(m, p) {
|
||||
t.Fatal("a merge a nanosecond later was not found as the later one")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user