MCPcopy
hub / github.com/cli/cli / TestNewCmdEdit

Function TestNewCmdEdit

pkg/cmd/pr/edit/edit_test.go:24–352  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func 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 },

Callers

nothing calls this directly

Calls 12

NewWithHostFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
JoinMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
NewCmdEditFunction · 0.70
RunMethod · 0.65
BaseRepoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected