Skip to content
quarry Artifact [a116da2835]
Login

Artifact [a116da2835]

Artifact a116da2835a0f93b8a77f0c3650abb90c17e2dd54b994c664b88b8247c992745:


package main

import (
	"path/filepath"
	"strings"
	"testing"

	"craftdesign.group/quarry/internal/api"
	"craftdesign.group/quarry/internal/ci"
	"craftdesign.group/quarry/internal/oltp"
	"craftdesign.group/quarry/internal/zitcli"
)

// A LANDING'S MERGE RUN TAGS NOTHING.
//
// Its subject is a pair, not a check-in, so a verdict tag has nowhere to
// go: writing one failed on every poll with "check-in 'pair:...' not
// found" (seen on zeitforge within minutes of the first merge run). The
// run is the verdict; carry-forward tags the merge once it exists.
func TestAMergeRunWritesNoVerdictTag(t *testing.T) {
	db, err := oltp.Open(filepath.Join(t.TempDir(), "o.db"))
	if err != nil {
		t.Fatal(err)
	}
	defer db.Close()
	if err := db.SetCITagsMode("r", "on"); err != nil {
		t.Fatal(err)
	}
	// A store that does not exist: any attempt to tag fails loudly.
	repos := api.NewRepos(map[string]*api.Repo{"r": {Zit: zitcli.New(filepath.Join(t.TempDir(), "nowhere"))}})
	pair := ci.Pair(strings.Repeat("a", 64), strings.Repeat("b", 64))
	run := oltp.CIRun{RunID: "run-1", Repo: "r", Checkin: pair, Pair: pair, Workflow: "w", Pipeline: "ci/quarry.json"}
	if err := writeVerdict(db, repos, true, run, ci.Run{Status: "completed"}); err != nil {
		t.Fatalf("FAIL: a merge run's verdict tried to tag the pair: %v", err)
	}
	t.Log("ok: a merge run writes no tag")
}