package web
import (
"strings"
"testing"
)
// quarry#290: the checks panel says which trunk the merge was tested
// against and, when trunk has moved, how far. A current verdict says
// no more than which trunk it tested.
func TestTheChecksSayWhichTrunkTheMergeTested(t *testing.T) {
tested := strings.Repeat("a", 64)
d := &landingDetail{landingRow: landingRow{ID: "cccc2222cccc", Branch: "feat", Target: "trunk", State: "open"},
Required: []string{"test"}, TestedAgainst: tested, TargetMovedBy: 3}
got := renderLandingBody(t, d)
for _, want := range []string{`data-hook="tested-against"`, `/checkin/` + tested, `data-hook="target-moved"`} {
if !strings.Contains(got, want) {
t.Errorf("FAIL: a panel tested against an older trunk misses %q", want)
}
}
d.TargetMovedBy = 0
if got := renderLandingBody(t, d); !strings.Contains(got, `data-hook="tested-against"`) || strings.Contains(got, `data-hook="target-moved"`) {
t.Errorf("FAIL: a current panel should name the trunk it tested and nothing more")
}
t.Log("ok: the panel names the trunk it tested, and a moved trunk only when it moved")
}