| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | |
| 8 | "reasonix/internal/event" |
| 9 | ) |
| 10 | |
| 11 | func TestWireEventTabPreservesSharedRetryingFields(t *testing.T) { |
| 12 | w := toWireTab(event.Event{Kind: event.Retrying, RetryAttempt: 3, RetryMax: 10}, "tab-1") |
| 13 | b, err := json.Marshal(w) |
| 14 | if err != nil { |
| 15 | t.Fatalf("marshal: %v", err) |
| 16 | } |
| 17 | s := string(b) |
| 18 | for _, want := range []string{`"kind":"retrying"`, `"retryAttempt":3`, `"retryMax":10`, `"tabId":"tab-1"`} { |
| 19 | if !strings.Contains(s, want) { |
| 20 | t.Fatalf("tab retrying JSON = %s, want it to contain %s", s, want) |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 |