oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package mergegate
2
3import (
4 "encoding/json"
5 "os"
6 "path/filepath"
7 "testing"
8
9 "amadan.net/oficina/equipo/internal/wire"
10)
11
12// This golden was measured on main 18fb5be4 before ChangeFiles existed.
13// It pins byte-identical decisions for identical inputs, including protocol 31.
14func TestPresentationFactsLeaveReviewGateUnchanged(t *testing.T) {
15 cases := map[string]func(*Inputs){
16 "ordinary": func(*Inputs) {},
17 "checked": func(i *Inputs) { i.Checks = wire.ChecksPassed; i.Eligible = true },
18 "failed": func(i *Inputs) { i.Checks = wire.ChecksFailed },
19 "not-approved": func(i *Inputs) { i.Verdict = wire.VerdictChanges },
20 "held": func(i *Inputs) { i.Hold = "Wait" },
21 "large": func(i *Inputs) { i.Change.Files = 201; i.Change.Lines = 5000 },
22 "binary": func(i *Inputs) { i.Change.Binary = 1 },
23 "special": func(i *Inputs) { i.Change.Special = true },
24 "signing": func(i *Inputs) { i.Change.Signing = true },
25 "gate-files": func(i *Inputs) { i.Change.GateFilesChanged = true },
26 "short-review": func(i *Inputs) { i.Change.ReviewTruncated = true },
27 "incomplete": func(i *Inputs) { i.Change.Complete = false },
28 "missing": func(i *Inputs) { i.Change = nil },
29 "ask": func(i *Inputs) { i.Policy.Mode = ModeAsk },
30 "person": func(i *Inputs) { i.Person = true },
31 }
32 all := map[string]map[int]Decision{}
33 for name, change := range cases {
34 all[name] = map[int]Decision{}
35 for _, protocol := range []int{27, 28, 30, 31} {
36 in := passing()
37 in.Protocol = protocol
38 change(&in)
39 all[name][protocol] = Decide(in)
40 }
41 }
42 got, err := json.MarshalIndent(all, "", " ")
43 if err != nil {
44 t.Fatal(err)
45 }
46 got = append(got, '\n')
47 file := filepath.Join("testdata", "presentation-gate.json")
48 if os.Getenv("EQUIPO_CAPTURE_GATE_BASELINE") == "1" {
49 if err := os.MkdirAll("testdata", 0700); err != nil {
50 t.Fatal(err)
51 }
52 if err := os.WriteFile(file, got, 0600); err != nil {
53 t.Fatal(err)
54 }
55 }
56 want, err := os.ReadFile(file)
57 if err != nil {
58 t.Fatal(err)
59 }
60 if string(got) != string(want) {
61 t.Fatal("Review gate decisions changed from main baseline")
62 }
63}
64