MCPcopy Create free account
hub / github.com/basecamp/hey-cli / TestCompose

Function TestCompose

tests/smoke/compose_test.go:9–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func 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
43func TestComposeRequiresSubject(t *testing.T) {
44 heyFail(t, "compose", "-m", "no subject", "--json")

Callers

nothing calls this directly

Calls 6

uniqueIDFunction · 0.85
heyFunction · 0.85
assertContainsFunction · 0.85
dataAsFunction · 0.85
extractTopicIDFunction · 0.85
fetchHTMLFunction · 0.85

Tested by

no test coverage detected