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