(t *testing.T)
| 21 | } |
| 22 | |
| 23 | func 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\n\nAfter", |
| 38 | attachmentArgs: []attachmentArg{pngArg()}, |
| 39 | wantMarkdown: "Before\n\n\n\nAfter", |
| 40 | }, |
| 41 | { |
| 42 | name: "image embed inline keeps its markdown", |
| 43 | markdown: "The screen  looks wrong.", |
| 44 | attachmentArgs: []attachmentArg{pngArg()}, |
| 45 | wantMarkdown: "The screen  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\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: "  ", |
| 70 | attachmentArgs: []attachmentArg{mp4Arg()}, |
| 71 | wantMarkdown: " " + mp4URL + " ", |
| 72 | }, |
| 73 | { |
| 74 | name: "video embed inline degrades to a link", |
| 75 | markdown: "The failure  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 |
nothing calls this directly
no test coverage detected