| 1 | package planning |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/equipo/team" |
| 8 | "amadan.net/oficina/equipo/internal/taskplan" |
| 9 | ) |
| 10 | |
| 11 | func TestEvidencePlanContracts(t *testing.T) { |
| 12 | for _, kind := range []taskplan.Kind{taskplan.Feature, taskplan.RenderedChange, taskplan.Recommendation, taskplan.Investigation} { |
| 13 | t.Run(string(kind), func(t *testing.T) { |
| 14 | p := taskplan.BugPlan("task", 1) |
| 15 | p.Kind = kind |
| 16 | switch kind { |
| 17 | case taskplan.Feature: |
| 18 | p.Steps[0].Action = "scope" |
| 19 | case taskplan.RenderedChange: |
| 20 | p.Steps[0].Action = "copy" |
| 21 | p.Steps[1].Action = "design" |
| 22 | default: |
| 23 | p.Steps = []taskplan.Step{{Key: "scope", Action: "scope"}, {Key: "research", Action: "recommend"}, {Key: "merge", Action: "person"}} |
| 24 | } |
| 25 | e, err := EvidenceForPlan(p, strings.Repeat("a", 64), strings.Repeat("b", 64)) |
| 26 | if err != nil { |
| 27 | t.Fatal(err) |
| 28 | } |
| 29 | steps, err := ExecutionSteps(p) |
| 30 | if err != nil { |
| 31 | t.Fatal("evidence plan could not dispatch", err) |
| 32 | } |
| 33 | if kind == taskplan.Recommendation || kind == taskplan.Investigation { |
| 34 | if e.Predicate != "" { |
| 35 | t.Fatal("fabricated read predicate") |
| 36 | } |
| 37 | for _, st := range steps { |
| 38 | if st.Capability != team.CapResearch { |
| 39 | t.Fatal("read plan gained writer", st) |
| 40 | } |
| 41 | } |
| 42 | } else if kind == taskplan.RenderedChange && len(e.RequiredDecisions) != 2 { |
| 43 | t.Fatal("missing decision owners") |
| 44 | } |
| 45 | }) |
| 46 | } |
| 47 | } |
| 48 | |