Skip to content
quarry Artifact [d6c2bd4836]
Login

Artifact [d6c2bd4836]

Artifact d6c2bd4836ae7ff23d5c2eecb32da8587504d97cc2b6aaf0b189fcc6a4a8df36:


package web

import (
	"strings"
	"testing"
)

// A failing trunk puts a dot inside the Timeline tab; a passing one
// leaves the tab exactly as it was.
func TestAFailingTrunkMarksTheTimelineTab(t *testing.T) {
	link := navlink("/r/q", "timeline", "Timeline", "", true, 12)
	if got := withdot(link, false); got != link {
		t.Errorf("FAIL: a green trunk changed the tab: %s", got)
	}
	got := string(withdot(link, true))
	i, j := strings.Index(got, `data-hook="trunk-red"`), strings.LastIndex(got, "</a>")
	if i < 0 || j < i {
		t.Errorf("FAIL: a red trunk has no dot inside the tab: %s", got)
	}
}

// Just accepted, the merge's run is still going: the record says the
// merge is being checked, not that the branch's checks passed.
func TestAnAcceptedLandingSaysItsMergeIsBeingChecked(t *testing.T) {
	l := landingDetail{MergeCI: "ci-run", MergeCIRun: "run1"}
	l.State = "accepted"
	s := l.ChecksSummary()
	if s.State != "wait" || !s.Merge {
		t.Errorf("FAIL: a running merge reads as %+v", s)
	}
}