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, 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) } for _, c := range []string{"mesh/merge-gate", "mesh/repo-check", "other/x"} { if !has(strs(rule["status_check_contexts"]), c) { t.Errorf("a status was dropped: %v", 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:], ", ")) } }