| 1 | package control |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/event" |
| 7 | "reasonix/internal/provider" |
| 8 | ) |
| 9 | |
| 10 | func TestTerminalFailureClassificationPreservesCancellation(t *testing.T) { |
| 11 | for _, terminal := range []event.Event{ |
| 12 | {Kind: event.TurnDone, Cancelled: true}, |
| 13 | {Kind: event.TurnDone, Cancelled: true, Err: provider.ErrNoDeliverableOutput}, |
| 14 | } { |
| 15 | got := withTerminalFailureDiagnostic(terminal) |
| 16 | if got.Diagnostic == nil || got.Diagnostic.Kind != provider.FailureKindCancelled { |
| 17 | t.Fatalf("cancellation relabelled as delivery failure: %+v", got.Diagnostic) |
| 18 | } |
| 19 | } |
| 20 | existing := &provider.FailureDiagnostic{Kind: "transport_protocol", ProviderID: "fixture"} |
| 21 | got := withTerminalFailureDiagnostic(event.Event{Kind: event.TurnDone, Diagnostic: existing}) |
| 22 | if got.Diagnostic != existing || got.Detail != "Connection ID: fixture" { |
| 23 | t.Fatalf("existing classification lost: %+v", got) |
| 24 | } |
| 25 | } |
| 26 |