(t *testing.T)
| 43 | } |
| 44 | |
| 45 | func TestCommentablePreRun(t *testing.T) { |
| 46 | tests := []struct { |
| 47 | name string |
| 48 | input string |
| 49 | canPrompt bool |
| 50 | wantErr string |
| 51 | // wantErrIsNotExist covers an error whose text the operating system |
| 52 | // words differently, so the assertion cannot be on the message. |
| 53 | wantErrIsNotExist bool |
| 54 | wantInputType InputType |
| 55 | wantAssetPaths []string |
| 56 | wantInteractive bool |
| 57 | wantBodyProvided bool |
| 58 | }{ |
| 59 | { |
| 60 | name: "attach alone is a body input and is resolved", |
| 61 | input: "--attach ./shot.png", |
| 62 | wantInputType: InputTypeInline, |
| 63 | wantAssetPaths: []string{"./shot.png"}, |
| 64 | }, |
| 65 | { |
| 66 | name: "attach with body is still resolved", |
| 67 | input: "--attach ./shot.png --body 'see below'", |
| 68 | wantInputType: InputTypeInline, |
| 69 | wantBodyProvided: true, |
| 70 | wantAssetPaths: []string{"./shot.png"}, |
| 71 | }, |
| 72 | { |
| 73 | name: "a file that does not exist stops the command", |
| 74 | input: "--attach ./gone.png", |
| 75 | wantErr: "./gone.png: ", |
| 76 | wantErrIsNotExist: true, |
| 77 | }, |
| 78 | { |
| 79 | // `--body ""` clears a comment, and only the flag being present can |
| 80 | // say so. |
| 81 | name: "attach with an empty body", |
| 82 | input: "--attach ./shot.png --body ''", |
| 83 | wantInputType: InputTypeInline, |
| 84 | wantBodyProvided: true, |
| 85 | wantAssetPaths: []string{"./shot.png"}, |
| 86 | }, |
| 87 | { |
| 88 | name: "attach with body-file", |
| 89 | input: "--attach ./shot.png --body-file ./body.md", |
| 90 | wantInputType: InputTypeInline, |
| 91 | wantBodyProvided: true, |
| 92 | wantAssetPaths: []string{"./shot.png"}, |
| 93 | }, |
| 94 | { |
| 95 | name: "attach with editor", |
| 96 | input: "--attach ./shot.png --editor", |
| 97 | wantInputType: InputTypeEditor, |
| 98 | wantAssetPaths: []string{"./shot.png"}, |
| 99 | }, |
| 100 | { |
| 101 | name: "attach with web", |
| 102 | input: "--attach ./shot.png --web", |
nothing calls this directly
no test coverage detected