Skip to content
quarry Artifact [cd0a0cbab3]
Login

Artifact [cd0a0cbab3]

Artifact cd0a0cbab3810374a5509e0e269cdbfe1289179232bfdc1905f53901d7655fdb:


package web

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

// The CI page of a repository with no CI, as the three people who can
// reach it see it: an admin (instructions and the decline), a developer
// (instructions, no decline, the admin-only step marked), and a reader
// holding the CI letter who has no part in setting it up (the plain fact).
// A fixture because the page has no other way to be looked at without a
// running forge, a session and a repository that has never run a step.
func TestWriteCISetupShots(t *testing.T) {
	dir := os.Getenv("QUARRY_SHOT_CISETUP")
	if dir == "" {
		t.Skip("QUARRY_SHOT_CISETUP unset")
	}
	if err := os.WriteFile(filepath.Join(dir, "quarry.css"), []byte(sheet), 0o644); err != nil {
		t.Fatal(err)
	}
	for name, d := range map[string]pageData{
		"admin":     {MaySetUpCI: true, CanAckGate: true, WorkerGroup: "orchard"},
		"developer": {MaySetUpCI: true, WorkerGroup: "orchard"},
		"reader":    {},
	} {
		d.Title, d.Repo, d.SheetURL = "CI", "orchard", "quarry.css"
		var buf strings.Builder
		if err := ciPage.Execute(&buf, d); err != nil {
			t.Fatal(err)
		}
		if err := os.WriteFile(filepath.Join(dir, "ci-"+name+".html"), []byte(buf.String()), 0o644); err != nil {
			t.Fatal(err)
		}
	}
}