Skip to content
quarry Artifact [31f3a081e9]
Login

Artifact [31f3a081e9]

Artifact 31f3a081e9ebeef9284e81f2a97e53e08644de13bffa642aab7c69f5285107d2:


package index

import "testing"

// A BRANCH TURNED DOWN HAS BEEN ANSWERED, UNTIL IT MOVES.
//
// The landings page listed three rejected probe branches under "work
// nobody has proposed". RejectedAt gives each branch whose newest
// landing was rejected the time of the rejection, so the list can skip
// a branch still sitting at that work and show it again once someone
// adds to it.
func TestRejectedAtNamesTheBranchesTurnedDown(t *testing.T) {
	ix := openIndex(t)
	foldForumBody(t, ix, "aaaa1111", "", "land probe", "2026-01-01T10:00:00", landingBody("probe", "trunk", "try"))
	foldForumBody(t, ix, "aaaa2222", "aaaa1111", "", "2026-01-02T10:00:00", landingState("rejected", "probe done"))
	foldForumBody(t, ix, "bbbb1111", "", "land open", "2026-01-01T10:00:00", landingBody("still-open", "trunk", "ready"))
	// Rejected, then proposed again: the newest landing is open, so the
	// branch is spoken for and not in the map.
	foldForumBody(t, ix, "cccc1111", "", "first try", "2026-01-01T10:00:00", landingBody("retried", "trunk", "v1"))
	foldForumBody(t, ix, "cccc2222", "cccc1111", "", "2026-01-01T12:00:00", landingState("rejected", "not yet"))
	foldForumBody(t, ix, "cccc3333", "", "second try", "2026-01-03T10:00:00", landingBody("retried", "trunk", "v2"))

	got, err := ix.RejectedAt()
	if err != nil {
		t.Fatal(err)
	}
	if got["probe"] != "2026-01-02T10:00:00" {
		t.Errorf("FAIL: probe rejected at %q, want the rejecting reply's date", got["probe"])
	}
	for _, b := range []string{"still-open", "retried"} {
		if at, ok := got[b]; ok {
			t.Errorf("FAIL: %s reads as rejected (%q), but its newest landing is open", b, at)
		}
	}
}