Skip to content
quarry Artifact [9fb145da4a]
Login

Artifact [9fb145da4a]

Artifact 9fb145da4a7627e6211868ac7a22ff96446987c5990252f444b4bb136412cf47:


package web

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

	"craftdesign.group/quarry/internal/ci"
)

// A LOOKING aid for the run page: three finished steps, one of them
// open with output. Off unless QUARRY_SHOT_RUN is set.
func TestWriteRunShot(t *testing.T) {
	out := os.Getenv("QUARRY_SHOT_RUN")
	if out == "" {
		t.Skip("QUARRY_SHOT_RUN unset")
	}
	if err := os.WriteFile(filepath.Join(filepath.Dir(out), "quarry.css"),
		[]byte(sheet), 0o644); err != nil {
		t.Fatal(err)
	}
	v := &ciRunView{
		Row: ciRunRow{RunID: "d0497ba9dd3a5a1b", Pipeline: "ci/quarry.json",
			Checkin: "56b2707249ec9f01", Branch: "trunk", User: "dmestas",
			Comment: "land warm-deadline", Status: "pass",
			Started: "2026-09-16T17:00:00Z"},
		Duration: "19s", Anchor: "d0497ba9dd3a",
		Steps: []ciStepView{
			{ID: "test", Status: "completed", State: "pass", Duration: "19s"},
			{ID: "fmt", Status: "completed", State: "pass", Duration: "2s"},
			{ID: "build", Status: "completed", State: "pass", Duration: "7s", Open: true,
				Chunks: []ci.LogChunk{
					{Seq: 1, Stream: "out", Data: "go build ./..."},
					{Seq: 2, Stream: "out", Data: "ok  craftdesign.group/quarry/internal/web"},
					{Seq: 3, Stream: "err", Data: "warning: one line on the error stream"},
				}},
		},
	}
	var buf strings.Builder
	if err := noHooks.template(ciRunPage).Execute(&buf, pageData{Title: "Run", OwnH1: true, Repo: "quarry",
		SheetURL: "quarry.css", CIRunView: v, CanTrigger: true}); err != nil {
		t.Fatal(err)
	}
	if err := os.WriteFile(out, []byte(buf.String()), 0o644); err != nil {
		t.Fatal(err)
	}
}