(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func TestNewCmdComment(t *testing.T) { |
| 30 | tmpFile := filepath.Join(t.TempDir(), "my-body.md") |
| 31 | err := os.WriteFile(tmpFile, []byte("a body from file"), 0600) |
| 32 | require.NoError(t, err) |
| 33 | |
| 34 | tmpImage := filepath.Join(t.TempDir(), "login.png") |
| 35 | require.NoError(t, os.WriteFile(tmpImage, []byte("the bytes"), 0600)) |
| 36 | |
| 37 | tests := []struct { |
| 38 | name string |
| 39 | input string |
| 40 | stdin string |
| 41 | output shared.CommentableOptions |
| 42 | wantsErr bool |
| 43 | wantsErrContains string |
| 44 | isTTY bool |
| 45 | |
| 46 | // Which fields the lookup asks for is decided at construction, so it |
| 47 | // can only be proved here. |
| 48 | queryWants string |
| 49 | queryOmits string |
| 50 | }{ |
| 51 | { |
| 52 | name: "no arguments", |
| 53 | input: "", |
| 54 | output: shared.CommentableOptions{ |
| 55 | Interactive: true, |
| 56 | InputType: 0, |
| 57 | Body: "", |
| 58 | }, |
| 59 | isTTY: true, |
| 60 | wantsErr: false, |
| 61 | }, |
| 62 | { |
| 63 | name: "two arguments", |
| 64 | input: "1 2", |
| 65 | output: shared.CommentableOptions{}, |
| 66 | isTTY: true, |
| 67 | wantsErr: true, |
| 68 | }, |
| 69 | { |
| 70 | name: "pr number", |
| 71 | input: "1", |
| 72 | output: shared.CommentableOptions{ |
| 73 | Interactive: true, |
| 74 | InputType: 0, |
| 75 | Body: "", |
| 76 | }, |
| 77 | isTTY: true, |
| 78 | wantsErr: false, |
| 79 | }, |
| 80 | { |
| 81 | name: "pr url", |
| 82 | input: "https://github.com/OWNER/REPO/pull/12", |
| 83 | output: shared.CommentableOptions{ |
| 84 | Interactive: true, |
| 85 | InputType: 0, |
| 86 | Body: "", |
nothing calls this directly
no test coverage detected