The forge's required status was a second copy of the gate mesh-delivery and the merge tool already keep; a stuck status writer held it too (issues 1886, 1891) and only a hand change at the forge let a fix merge. Main keeps no push, the tools' merge whitelist and no administrator override. The merge tool judges mesh/check whether or not the branch requires it, and on a branch that requires none merges only a head the operator's Approve names. The protection tool loses its status argument.
48 lines
1.9 KiB
Go
48 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// 1141/AC1: a repository the program makes gets main's rule with an administrator's merge past it 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 taken off (ADR 0534 §1), 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 !requiresNone(rule) {
|
|
t.Errorf("statuses %v, want none (ADR 0534 §1)", rule["status_check_contexts"])
|
|
}
|
|
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:], ", "))
|
|
}
|
|
}
|