(t *testing.T)
| 34 | ) |
| 35 | |
| 36 | func TestNewCmdEdit(t *testing.T) { |
| 37 | tmpFile := filepath.Join(t.TempDir(), "my-body.md") |
| 38 | err := os.WriteFile(tmpFile, []byte("a body from file"), 0600) |
| 39 | require.NoError(t, err) |
| 40 | |
| 41 | tmpImage := filepath.Join(t.TempDir(), "shot.png") |
| 42 | require.NoError(t, os.WriteFile(tmpImage, []byte("the bytes"), 0600)) |
| 43 | |
| 44 | tests := []struct { |
| 45 | name string |
| 46 | input string |
| 47 | stdin string |
| 48 | output EditOptions |
| 49 | expectedBaseRepo ghrepo.Interface |
| 50 | wantAssetPaths []string |
| 51 | wantsErr bool |
| 52 | wantsErrMsg string |
| 53 | // wantErrIsNotExist covers an error whose text the operating system |
| 54 | // words differently, so the assertion cannot be on the message. |
| 55 | wantErrIsNotExist bool |
| 56 | }{ |
| 57 | { |
| 58 | name: "no argument", |
| 59 | input: "", |
| 60 | output: EditOptions{}, |
| 61 | wantsErr: true, |
| 62 | }, |
| 63 | { |
| 64 | name: "issue number argument", |
| 65 | input: "23", |
| 66 | output: EditOptions{ |
| 67 | IssueNumbers: []int{23}, |
| 68 | Interactive: true, |
| 69 | }, |
| 70 | wantsErr: false, |
| 71 | }, |
| 72 | { |
| 73 | name: "title flag", |
| 74 | input: "23 --title test", |
| 75 | output: EditOptions{ |
| 76 | IssueNumbers: []int{23}, |
| 77 | Editable: prShared.Editable{ |
| 78 | Title: prShared.EditableString{ |
| 79 | Value: "test", |
| 80 | Edited: true, |
| 81 | }, |
| 82 | }, |
| 83 | }, |
| 84 | wantsErr: false, |
| 85 | }, |
| 86 | { |
| 87 | name: "body flag", |
| 88 | input: "23 --body test", |
| 89 | output: EditOptions{ |
| 90 | IssueNumbers: []int{23}, |
| 91 | Editable: prShared.Editable{ |
| 92 | Body: prShared.EditableString{ |
| 93 | Value: "test", |
nothing calls this directly
no test coverage detected