(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestNewCmdCreate(t *testing.T) { |
| 19 | tests := []struct { |
| 20 | name string |
| 21 | args string |
| 22 | isTTY bool |
| 23 | wantOpts CreateOptions |
| 24 | wantBaseRepo ghrepo.Interface |
| 25 | wantErr string |
| 26 | }{ |
| 27 | { |
| 28 | name: "no flags", |
| 29 | args: "", |
| 30 | isTTY: true, |
| 31 | wantOpts: CreateOptions{}, |
| 32 | }, |
| 33 | { |
| 34 | name: "all flags", |
| 35 | args: "--title 'My question' --body 'Details' --category 'Q&A' --label bug,enhancement", |
| 36 | isTTY: true, |
| 37 | wantOpts: CreateOptions{ |
| 38 | Title: "My question", |
| 39 | Body: "Details", |
| 40 | Category: "Q&A", |
| 41 | Labels: []string{"bug", "enhancement"}, |
| 42 | }, |
| 43 | }, |
| 44 | { |
| 45 | name: "extra args", |
| 46 | args: "extra", |
| 47 | isTTY: true, |
| 48 | wantErr: "unknown argument", |
| 49 | }, |
| 50 | { |
| 51 | name: "missing required flags non-interactively", |
| 52 | args: "--title 'My question'", |
| 53 | isTTY: false, |
| 54 | wantErr: "--title, --body (or --body-file), and --category are required when not running interactively", |
| 55 | }, |
| 56 | { |
| 57 | name: "blank title", |
| 58 | args: "--title ' '", |
| 59 | isTTY: true, |
| 60 | wantErr: "title cannot be blank", |
| 61 | }, |
| 62 | { |
| 63 | name: "blank category", |
| 64 | args: "--category ' '", |
| 65 | isTTY: true, |
| 66 | wantErr: "category cannot be blank", |
| 67 | }, |
| 68 | { |
| 69 | name: "blank body", |
| 70 | args: "--body ' '", |
| 71 | isTTY: true, |
| 72 | wantErr: "body cannot be blank", |
| 73 | }, |
| 74 | { |
| 75 | name: "body and body-file mutually exclusive", |
nothing calls this directly
no test coverage detected