(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestNewCmdEdit(t *testing.T) { |
| 21 | tests := []struct { |
| 22 | name string |
| 23 | args string |
| 24 | isTTY bool |
| 25 | wantOpts EditOptions |
| 26 | wantBaseRepo ghrepo.Interface |
| 27 | wantErr string |
| 28 | }{ |
| 29 | { |
| 30 | name: "all flags", |
| 31 | args: "123 --title 'New title' --body 'New body' --category 'Ideas'", |
| 32 | isTTY: true, |
| 33 | wantOpts: EditOptions{ |
| 34 | DiscussionNumber: 123, |
| 35 | TitleProvided: true, |
| 36 | Title: "New title", |
| 37 | BodyProvided: true, |
| 38 | Body: "New body", |
| 39 | CategoryProvided: true, |
| 40 | Category: "Ideas", |
| 41 | }, |
| 42 | }, |
| 43 | { |
| 44 | name: "url arg overrides base repo", |
| 45 | args: "https://github.com/OWNER2/REPO2/discussions/42", |
| 46 | isTTY: true, |
| 47 | wantOpts: EditOptions{ |
| 48 | DiscussionNumber: 42, |
| 49 | Interactive: true, |
| 50 | }, |
| 51 | wantBaseRepo: ghrepo.New("OWNER2", "REPO2"), |
| 52 | }, |
| 53 | { |
| 54 | name: "interactive mode when no flags and tty", |
| 55 | args: "123", |
| 56 | isTTY: true, |
| 57 | wantOpts: EditOptions{ |
| 58 | DiscussionNumber: 123, |
| 59 | Interactive: true, |
| 60 | }, |
| 61 | }, |
| 62 | { |
| 63 | name: "labels flags", |
| 64 | args: "123 --add-label 'bug,help wanted' --remove-label stale", |
| 65 | isTTY: true, |
| 66 | wantOpts: EditOptions{ |
| 67 | DiscussionNumber: 123, |
| 68 | AddLabels: []string{"bug", "help wanted"}, |
| 69 | RemoveLabels: []string{"stale"}, |
| 70 | LabelsProvided: true, |
| 71 | }, |
| 72 | }, |
| 73 | { |
| 74 | name: "mutual exclusion --body and --body-file", |
| 75 | args: "123 --body 'inline' --body-file body.md", |
| 76 | isTTY: true, |
| 77 | wantErr: "specify only one of --body or --body-file", |
nothing calls this directly
no test coverage detected