(t *testing.T)
| 23 | } |
| 24 | |
| 25 | func TestAttachAssetsToMarkdown(t *testing.T) { |
| 26 | absPNG, err := filepath.Abs("./login.png") |
| 27 | require.NoError(t, err) |
| 28 | |
| 29 | // The rows with a markdownDir read as though the markdown came from |
| 30 | // docs/plan.md, with the diagram beside it. |
| 31 | docsPNG := attachmentArg{Path: "docs/diagram.png", URL: pngURL, Alt: "diagram"} |
| 32 | workingDirPNG := attachmentArg{Path: "./diagram.png", URL: "https://example.com/working-dir", Alt: "diagram"} |
| 33 | |
| 34 | tests := []struct { |
| 35 | name string |
| 36 | markdown string |
| 37 | markdownDir string |
| 38 | attachmentArgs []attachmentArg |
| 39 | wantMarkdown string |
| 40 | wantToAppend []attachmentArg |
| 41 | wantErr string |
| 42 | }{ |
| 43 | { |
| 44 | name: "image embed on its own line keeps its markdown", |
| 45 | markdown: "Before\n\n\n\nAfter", |
| 46 | attachmentArgs: []attachmentArg{pngArg()}, |
| 47 | wantMarkdown: "Before\n\n\n\nAfter", |
| 48 | }, |
| 49 | { |
| 50 | name: "image embed inline keeps its markdown", |
| 51 | markdown: "The screen  looks wrong.", |
| 52 | attachmentArgs: []attachmentArg{pngArg()}, |
| 53 | wantMarkdown: "The screen  looks wrong.", |
| 54 | }, |
| 55 | { |
| 56 | name: "image link stays a link", |
| 57 | markdown: "See [the screenshot](./login.png) for detail.", |
| 58 | attachmentArgs: []attachmentArg{pngArg()}, |
| 59 | wantMarkdown: "See [the screenshot](" + pngURL + ") for detail.", |
| 60 | }, |
| 61 | { |
| 62 | name: "image never referenced is reported for appending", |
| 63 | markdown: "No references here.", |
| 64 | attachmentArgs: []attachmentArg{pngArg()}, |
| 65 | wantMarkdown: "No references here.", |
| 66 | wantToAppend: []attachmentArg{pngArg()}, |
| 67 | }, |
| 68 | |
| 69 | { |
| 70 | name: "video embed alone in its own paragraph becomes a bare url", |
| 71 | markdown: "Watch:\n\n\n\nEnd", |
| 72 | attachmentArgs: []attachmentArg{mp4Arg()}, |
| 73 | wantMarkdown: "Watch:\n\n" + mp4URL + "\n\nEnd", |
| 74 | }, |
| 75 | { |
| 76 | name: "video embed alone in a paragraph padded with spaces becomes a bare url", |
| 77 | markdown: "  ", |
| 78 | attachmentArgs: []attachmentArg{mp4Arg()}, |
| 79 | wantMarkdown: " " + mp4URL + " ", |
| 80 | }, |
| 81 | { |
| 82 | name: "video embed inline degrades to a link", |
nothing calls this directly
no test coverage detected