(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestNewCmdComment(t *testing.T) { |
| 25 | tmpFile := filepath.Join(t.TempDir(), "my-body.md") |
| 26 | err := os.WriteFile(tmpFile, []byte("a body from file"), 0600) |
| 27 | require.NoError(t, err) |
| 28 | |
| 29 | tests := []struct { |
| 30 | name string |
| 31 | input string |
| 32 | stdin string |
| 33 | output shared.CommentableOptions |
| 34 | wantsErr bool |
| 35 | isTTY bool |
| 36 | }{ |
| 37 | { |
| 38 | name: "no arguments", |
| 39 | input: "", |
| 40 | output: shared.CommentableOptions{ |
| 41 | Interactive: true, |
| 42 | InputType: 0, |
| 43 | Body: "", |
| 44 | }, |
| 45 | isTTY: true, |
| 46 | wantsErr: false, |
| 47 | }, |
| 48 | { |
| 49 | name: "two arguments", |
| 50 | input: "1 2", |
| 51 | output: shared.CommentableOptions{}, |
| 52 | isTTY: true, |
| 53 | wantsErr: true, |
| 54 | }, |
| 55 | { |
| 56 | name: "pr number", |
| 57 | input: "1", |
| 58 | output: shared.CommentableOptions{ |
| 59 | Interactive: true, |
| 60 | InputType: 0, |
| 61 | Body: "", |
| 62 | }, |
| 63 | isTTY: true, |
| 64 | wantsErr: false, |
| 65 | }, |
| 66 | { |
| 67 | name: "pr url", |
| 68 | input: "https://github.com/OWNER/REPO/pull/12", |
| 69 | output: shared.CommentableOptions{ |
| 70 | Interactive: true, |
| 71 | InputType: 0, |
| 72 | Body: "", |
| 73 | }, |
| 74 | isTTY: true, |
| 75 | wantsErr: false, |
| 76 | }, |
| 77 | { |
| 78 | name: "pr branch", |
| 79 | input: "branch-name", |
| 80 | output: shared.CommentableOptions{ |
| 81 | Interactive: true, |
nothing calls this directly
no test coverage detected