(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestCompose(t *testing.T) { |
| 10 | uid := uniqueID() |
| 11 | subject := fmt.Sprintf("Smoke test %s", uid) |
| 12 | |
| 13 | stdout, stderr, code := hey(t, "compose", |
| 14 | "--to", "david@basecamp.com", |
| 15 | "--subject", subject, |
| 16 | "-m", "Hello from smoke test", |
| 17 | "--json", |
| 18 | ) |
| 19 | if code != 0 { |
| 20 | t.Fatalf("compose failed (exit %d): %s", code, stderr) |
| 21 | } |
| 22 | |
| 23 | var resp Response |
| 24 | if err := json.Unmarshal([]byte(stdout), &resp); err != nil { |
| 25 | t.Fatalf("failed to parse compose response: %v", err) |
| 26 | } |
| 27 | if !resp.OK { |
| 28 | t.Fatal("compose returned ok=false") |
| 29 | } |
| 30 | assertContains(t, resp.Summary, "Message sent") |
| 31 | |
| 32 | // Cross-verify: fetch the thread page and check the subject appears. |
| 33 | composeData := dataAs[map[string]any](t, resp) |
| 34 | if appURL, ok := composeData["app_url"].(string); ok { |
| 35 | topicID := extractTopicID(appURL) |
| 36 | if topicID != "" { |
| 37 | html := fetchHTML(t, fmt.Sprintf("%s/topics/%s", baseURL, topicID)) |
| 38 | assertContains(t, html, subject) |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func TestComposeRequiresSubject(t *testing.T) { |
| 44 | heyFail(t, "compose", "-m", "no subject", "--json") |
nothing calls this directly
no test coverage detected