ADR 0447 §1 has main require mesh/check alone. The repositories program now requires it in place of mesh/merge-gate and mesh/repo-check on every listed repository and on every other one whose main requires mesh/merge-gate, so the switch needs no hand-kept list (lead decisions L4, L11). A main requiring mesh/repo-check alone (hq) keeps it until issue 1296 (ADR 0503 §5).
48 lines
2.0 KiB
Go
48 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// 1141/AC1: a repository the program makes gets main's rule with an administrator's merge past a status refused,
|
|
// as every repository's main has had since 2026-10-07.
|
|
func TestNewRepositoryRefusesTheAdministratorsOverride(t *testing.T) {
|
|
f := newFake()
|
|
s, _ := syncer(t, f)
|
|
run(t, s, Value{"mesh-delivery": {Description: "d"}})
|
|
rule := f.repos["novox/mesh-delivery"].Rules[mainRule]
|
|
if rule["block_admin_merge_override"] != true {
|
|
t.Errorf("main lets an administrator merge past its statuses: %v", rule)
|
|
}
|
|
}
|
|
|
|
// 1141/AC2: a narrowed main rule that still lets an administrator override is not right: it is put right, its
|
|
// statuses kept (the two old ones as mesh/check, issue 1301), and a second pass changes nothing.
|
|
func TestNarrowedRuleLettingTheAdministratorOverrideIsPutRight(t *testing.T) {
|
|
f := newFake()
|
|
repo := f.add("novox/mesh-delivery", map[string]map[string]any{mainRule: {
|
|
"enable_push": false, "enable_push_whitelist": false, "push_whitelist_usernames": []any{},
|
|
"enable_merge_whitelist": true, "merge_whitelist_usernames": []any{tools},
|
|
"enable_status_check": true, "status_check_contexts": []any{"mesh/merge-gate", "mesh/repo-check", "other/x"},
|
|
"block_admin_merge_override": false,
|
|
}}, "main")
|
|
s, _ := syncer(t, f)
|
|
o := run(t, s, Value{"mesh-delivery": {Description: "d"}})
|
|
rule := repo.Rules[mainRule]
|
|
if rule["block_admin_merge_override"] != true {
|
|
t.Errorf("the administrator's override is still allowed: %v", rule)
|
|
}
|
|
if c := strs(rule["status_check_contexts"]); strings.Join(c, ",") != "other/x,mesh/check" {
|
|
t.Errorf("statuses %v, want other/x kept and mesh/check for the two it replaces (issue 1301)", c)
|
|
}
|
|
if r := result(o, "mesh-delivery"); r.Did != DidPutRight {
|
|
t.Errorf("outcome %+v, want put right", r)
|
|
}
|
|
before := len(f.writes())
|
|
run(t, s, Value{"mesh-delivery": {Description: "d"}})
|
|
if got := f.writes(); len(got) != before {
|
|
t.Errorf("a second pass wrote %s", strings.Join(got[before:], ", "))
|
|
}
|
|
}
|