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