Skip to content
quarry Artifact [7260b9c7f7]
Login

Artifact [7260b9c7f7]

Artifact 7260b9c7f7d1714eb7a2bc9decece3cb30f60bae709a1acdb5b5360a0e845f2b:


package web

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

// The fleet's mirror form with the unversioned import and its login,
// and a repository's Mirror section with the import line, written as
// pages to look at (RFC 0020 rung 6): fleet-uv.html editing a mirror
// that imports, fleet-uv-blocked.html one whose store has no bucket,
// settings-uv.html the section after a round that skipped a file.
func TestWriteMirrorUVShots(t *testing.T) {
	dir := os.Getenv("QUARRY_SHOT_MIRRORUV")
	if dir == "" {
		t.Skip("QUARRY_SHOT_MIRRORUV unset")
	}
	if err := os.WriteFile(filepath.Join(dir, "quarry.css"), []byte(sheet), 0o644); err != nil {
		t.Fatal(err)
	}
	write := func(name string, p *pageTemplate, d pageData) {
		var buf strings.Builder
		if err := noHooks.template(p).Execute(&buf, d); err != nil {
			t.Fatal(err)
		}
		if err := os.WriteFile(filepath.Join(dir, name), []byte(buf.String()), 0o644); err != nil {
			t.Fatal(err)
		}
	}
	on := mirrorRow{Repo: "sqlite", URL: "https://sqlite.org/src", Enabled: true, Every: 3600, State: "current",
		UV: true, UVUser: "puller", UVCredential: true}
	write("fleet-uv.html", fleetAdminPage, pageData{Title: "Fleet", SheetURL: "quarry.css", FleetTab: "mirrors",
		Mirrors: []mirrorRow{on}, MirrorCounts: map[string]int{"all": 1, "current": 1}, MirrorEdit: &on})
	blocked := mirrorRow{Repo: "tcl", URL: "https://core.tcl-lang.org/tcl", Enabled: true, Every: 3600, State: "current",
		UVBlocked: "the repository has no bucket of its own to put them in; bind one in its Settings"}
	write("fleet-uv-blocked.html", fleetAdminPage, pageData{Title: "Fleet", SheetURL: "quarry.css", FleetTab: "mirrors",
		Mirrors: []mirrorRow{blocked}, MirrorCounts: map[string]int{"all": 1, "current": 1}, MirrorEdit: &blocked})
	d := pageData{Title: "Settings", SheetURL: "quarry.css", Repo: "sqlite", Caps: &capsPanel{}, RepoAdmin: true, IsAdmin: true}
	d.Posture.Mirror.Tracking, d.Posture.Mirror.URL, d.Posture.Mirror.Every = true, "https://sqlite.org/src", 3600
	d.Posture.Mirror.State, d.Posture.Mirror.LastAt, d.Posture.Mirror.LastOK = "current", "2026-10-01T16:00:00Z", "2026-10-01T16:00:00Z"
	d.Posture.Mirror.UV, d.Posture.Mirror.UVAt, d.Posture.Mirror.UVChanged = true, "2026-10-01T16:00:00Z", 2
	d.Posture.Mirror.UVErr = "sqlite-src-3500000.zip: not carried (larger than this bucket's limit)"
	write("settings-uv.html", settingsPage, d)
}