package issue import ( "strings" "testing" "time" ) func Test_formatDiscussionMarkdown_includesIssueAndComments(t *testing.T) { created := time.Date(2026, 1, 2, 15, 4, 5, 0, time.UTC) commentTime := time.Date(2026, 1, 3, 9, 0, 0, 0, time.UTC) md := formatDiscussionMarkdown( discussionIssue{ Number: 42, Title: "bug with screenshot", Author: "octocat", State: "open", Labels: []string{"bug", "help wanted"}, Body: "see attached", CreatedAt: created, }, []discussionComment{ {Author: "reviewer", CreatedAt: commentTime, Body: "thanks for reporting"}, }, ) wantSubstrings := []string{ "# bug with screenshot (#42)", "**Author:** octocat", "**State:** open", "**Labels:** bug, help wanted", "**Created:** 2026-01-02T15:04:05Z", "see attached", "## Comments", "### reviewer", "2026-01-03T09:00:00Z", "thanks for reporting", } for _, want := range wantSubstrings { if !strings.Contains(md, want) { t.Fatalf("expected markdown to contain %q, got:\n%s", want, md) } } } func Test_formatDiscussionMarkdown_noComments(t *testing.T) { md := formatDiscussionMarkdown( discussionIssue{ Number: 1, Title: "no comments yet", Author: "octocat", State: "open", }, nil, ) if !strings.Contains(md, "## Comments") { t.Fatalf("expected a Comments section, got:\n%s", md) } if !strings.Contains(md, "_No comments yet._") { t.Fatalf("expected placeholder for no comments, got:\n%s", md) } } func Test_formatDiscussionMarkdown_attachmentBodyIsInlined(t *testing.T) { md := formatDiscussionMarkdown( discussionIssue{ Number: 7, Title: "with attachment", Author: "octocat", State: "open", Body: "see attached\n\n[shot.png](https://example/shot.png)", }, []discussionComment{ {Author: "reviewer", Body: "log attached\n\n[log.txt](https://example/log.txt)"}, }, ) if !strings.Contains(md, "[shot.png](https://example/shot.png)") { t.Fatalf("expected issue attachment link in markdown, got:\n%s", md) } if !strings.Contains(md, "[log.txt](https://example/log.txt)") { t.Fatalf("expected comment attachment link in markdown, got:\n%s", md) } }