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