(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestNewCmdEdit(t *testing.T) { |
| 29 | tmpFile := filepath.Join(t.TempDir(), "my-body.md") |
| 30 | err := os.WriteFile(tmpFile, []byte("a body from file"), 0600) |
| 31 | require.NoError(t, err) |
| 32 | |
| 33 | tests := []struct { |
| 34 | name string |
| 35 | input string |
| 36 | stdin string |
| 37 | output EditOptions |
| 38 | expectedBaseRepo ghrepo.Interface |
| 39 | wantsErr bool |
| 40 | }{ |
| 41 | { |
| 42 | name: "no argument", |
| 43 | input: "", |
| 44 | output: EditOptions{}, |
| 45 | wantsErr: true, |
| 46 | }, |
| 47 | { |
| 48 | name: "issue number argument", |
| 49 | input: "23", |
| 50 | output: EditOptions{ |
| 51 | IssueNumbers: []int{23}, |
| 52 | Interactive: true, |
| 53 | }, |
| 54 | wantsErr: false, |
| 55 | }, |
| 56 | { |
| 57 | name: "title flag", |
| 58 | input: "23 --title test", |
| 59 | output: EditOptions{ |
| 60 | IssueNumbers: []int{23}, |
| 61 | Editable: prShared.Editable{ |
| 62 | Title: prShared.EditableString{ |
| 63 | Value: "test", |
| 64 | Edited: true, |
| 65 | }, |
| 66 | }, |
| 67 | }, |
| 68 | wantsErr: false, |
| 69 | }, |
| 70 | { |
| 71 | name: "body flag", |
| 72 | input: "23 --body test", |
| 73 | output: EditOptions{ |
| 74 | IssueNumbers: []int{23}, |
| 75 | Editable: prShared.Editable{ |
| 76 | Body: prShared.EditableString{ |
| 77 | Value: "test", |
| 78 | Edited: true, |
| 79 | }, |
| 80 | }, |
| 81 | }, |
| 82 | wantsErr: false, |
| 83 | }, |
| 84 | { |
| 85 | name: "body from stdin", |
nothing calls this directly
no test coverage detected