MCPcopy Create free account
hub / github.com/cli/cli / TestAttachAssetsToMarkdown

Function TestAttachAssetsToMarkdown

internal/attachments/references_test.go:23–785  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func TestAttachAssetsToMarkdown(t *testing.T) {
24 absPNG, err := filepath.Abs("./login.png")
25 require.NoError(t, err)
26
27 tests := []struct {
28 name string
29 markdown string
30 attachmentArgs []attachmentArg
31 wantMarkdown string
32 wantToAppend []attachmentArg
33 wantErr string
34 }{
35 {
36 name: "image embed on its own line keeps its markdown",
37 markdown: "Before\n\n![the login screen](./login.png)\n\nAfter",
38 attachmentArgs: []attachmentArg{pngArg()},
39 wantMarkdown: "Before\n\n![the login screen](" + pngURL + ")\n\nAfter",
40 },
41 {
42 name: "image embed inline keeps its markdown",
43 markdown: "The screen ![the login screen](./login.png) looks wrong.",
44 attachmentArgs: []attachmentArg{pngArg()},
45 wantMarkdown: "The screen ![the login screen](" + pngURL + ") looks wrong.",
46 },
47 {
48 name: "image link stays a link",
49 markdown: "See [the screenshot](./login.png) for detail.",
50 attachmentArgs: []attachmentArg{pngArg()},
51 wantMarkdown: "See [the screenshot](" + pngURL + ") for detail.",
52 },
53 {
54 name: "image never referenced is reported for appending",
55 markdown: "No references here.",
56 attachmentArgs: []attachmentArg{pngArg()},
57 wantMarkdown: "No references here.",
58 wantToAppend: []attachmentArg{pngArg()},
59 },
60
61 {
62 name: "video embed alone in its own paragraph becomes a bare url",
63 markdown: "Watch:\n\n![screen recording](./repro.mp4)\n\nEnd",
64 attachmentArgs: []attachmentArg{mp4Arg()},
65 wantMarkdown: "Watch:\n\n" + mp4URL + "\n\nEnd",
66 },
67 {
68 name: "video embed alone in a paragraph padded with spaces becomes a bare url",
69 markdown: " ![screen recording](./repro.mp4) ",
70 attachmentArgs: []attachmentArg{mp4Arg()},
71 wantMarkdown: " " + mp4URL + " ",
72 },
73 {
74 name: "video embed inline degrades to a link",
75 markdown: "The failure ![screen recording](./repro.mp4) is reproducible.",
76 attachmentArgs: []attachmentArg{mp4Arg()},
77 wantMarkdown: "The failure [screen recording](" + mp4URL + ") is reproducible.",
78 },
79 {
80 // Dropping the "!" would leave the preceding one touching the

Callers

nothing calls this directly

Calls 6

pngArgFunction · 0.85
mp4ArgFunction · 0.85
newAttachableMarkdownFunction · 0.85
attachAssetsToMarkdownFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected