Skip to content
quarry Artifact [f566e74b24]
Login

Artifact [f566e74b24]

Artifact f566e74b24453a1aed93c7e5d919e23777caaabfee5d86821bd7da3c1045dd67:


package ci

import (
	"slices"
	"testing"
)

// A rerun of one run starts that run's pipeline alone, at the run's
// check-in, and hands back the new run's id.
func TestRerunRunStartsOnlyThePipelineOfTheRun(t *testing.T) {
	srv, started := startedEngine(t)
	e := New(srv.URL)
	st := &fakeStore{mark: map[string]string{}}
	repo := deployRepo()
	repo.branches = map[string]string{"t1": "trunk"}

	id, err := RerunRun(e, st, "alpha", repo, "http://x/r/alpha", "t1", "ci/test.json", "dan")
	if err != nil {
		t.Fatalf("FAIL: rerun: %v", err)
	}
	if id == "" {
		t.Errorf("FAIL: rerun returned no run id")
	}
	if got := started(); !slices.Equal(got, []string{"t1 ci/test.json"}) {
		t.Errorf("FAIL: rerun started %v, want only ci/test.json at t1", got)
	}
	if st.starts[id].Starter != "dan" {
		t.Errorf("FAIL: starter %q, want dan", st.starts[id].Starter)
	}

	if _, err := RerunRun(e, st, "alpha", repo, "http://x/r/alpha", "t1", "ci/gone.json", "dan"); err == nil {
		t.Errorf("FAIL: rerun of a pipeline the check-in no longer holds started something")
	}

	pid, err := RerunRun(e, st, "alpha", repo, "http://x/r/alpha", Pair("b2", "t1"), "ci/test.json", "dan")
	if err != nil || pid == "" {
		t.Errorf("FAIL: rerun of a pair run: id %q err %v", pid, err)
	}
	if !t.Failed() {
		t.Log("ok")
	}
}