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

Function TestNewCmdEdit

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

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
PathMethod · 0.65
BaseRepoMethod · 0.65

Tested by

no test coverage detected