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