Skip to content
quarry Artifact [36757486cd]
Login

Artifact [36757486cd]

Artifact 36757486cd96b1a731718c2fcf06eff6e3dc39a88f8d107cd87c1b9139119c83:


package web

import (
	"strings"
	"testing"
)

// quarry#290: in merge mode the checks panel says which trunk the
// merge was tested against and, when trunk has moved, that a re-test
// is waiting and the accept is allowed. A current verdict says no
// more than which trunk it tested.
func TestMergeModeSaysWhichTrunkItTested(t *testing.T) {
	tested := strings.Repeat("a", 64)
	d := &landingDetail{landingRow: landingRow{ID: "cccc2222cccc", Branch: "feat", Target: "trunk", State: "open"},
		Required: []string{"test"}, Premerge: true, MergeMode: true, 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 stale merge-mode panel 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 merge-mode 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")
}