MCPcopy Create free account
hub / github.com/cli/cli / TestNewCmdEdit

Function TestNewCmdEdit

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

Source from the content-addressed store, hash-verified

28)
29
30func 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{

Callers

nothing calls this directly

Calls 15

NewWithHostFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
JoinMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
ChangedMethod · 0.80
EqualMethod · 0.80
EmptyMethod · 0.80
NewCmdEditFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected