package wire_test import ( "encoding/json" "testing" "amadan.net/oficina/equipo/internal/wire" ) // A runner reports an Engineering step whose tool requests Equipo // refused as tools_refused, a reason on the wire beside no_changes. // no_further_changes is the instance's own reading of no_changes (a // candidate from an earlier round) and never travels: a runner that // sent it would be recorded as unknown. An older instance records // tools_refused as unknown rather than refusing the report; an older // runner never sends it, and its no_changes reads as before. func TestToolsRefusedIsAStepReason(t *testing.T) { if !wire.StepReasons["tools_refused"] || !wire.StepReasons["no_changes"] { t.Fatal("tools_refused and no_changes are step reasons") } if wire.StepReasons["no_further_changes"] { t.Fatal("no_further_changes is the instance's words, not a runner's reason") } raw, err := json.Marshal(wire.StepReport{TaskID: "tk1", StepID: "s1", Attempt: 1, State: wire.StepFailed, Reason: "tools_refused", Termination: true}) if err != nil { t.Fatal(err) } var back wire.StepReport if err := json.Unmarshal(raw, &back); err != nil || back.Reason != "tools_refused" { t.Fatalf("round trip %+v %v", back, err) } }