oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package wire_test
2
3import (
4 "encoding/json"
5 "testing"
6
7 "amadan.net/oficina/equipo/internal/wire"
8)
9
10// A runner reports an Engineering step whose tool requests Equipo
11// refused as tools_refused, a reason on the wire beside no_changes.
12// no_further_changes is the instance's own reading of no_changes (a
13// candidate from an earlier round) and never travels: a runner that
14// sent it would be recorded as unknown. An older instance records
15// tools_refused as unknown rather than refusing the report; an older
16// runner never sends it, and its no_changes reads as before.
17func TestToolsRefusedIsAStepReason(t *testing.T) {
18 if !wire.StepReasons["tools_refused"] || !wire.StepReasons["no_changes"] {
19 t.Fatal("tools_refused and no_changes are step reasons")
20 }
21 if wire.StepReasons["no_further_changes"] {
22 t.Fatal("no_further_changes is the instance's words, not a runner's reason")
23 }
24 raw, err := json.Marshal(wire.StepReport{TaskID: "tk1", StepID: "s1", Attempt: 1, State: wire.StepFailed, Reason: "tools_refused", Termination: true})
25 if err != nil {
26 t.Fatal(err)
27 }
28 var back wire.StepReport
29 if err := json.Unmarshal(raw, &back); err != nil || back.Reason != "tools_refused" {
30 t.Fatalf("round trip %+v %v", back, err)
31 }
32}
33