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

Function TestNewCmdEdit

pkg/cmd/pr/edit/edit_test.go:30–430  ·  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 attachmentEvent := []ghtelemetry.Event{{
39 Type: "attachment_invocation",
40 Dimensions: ghtelemetry.Dimensions{"command": "edit"},
41 Measures: ghtelemetry.Measures{
42 "attach_count": 1, "append_ops_count": 0, "replace_ops_count": 0,
43 },
44 }}
45
46 tests := []struct {
47 name string
48 input string
49 stdin string
50 output EditOptions
51 wantAssetPaths []string
52 expectedBaseRepo ghrepo.Interface
53 wantsErr bool
54 wantEvents []ghtelemetry.Event
55 wantSampleRate int
56 }{
57 {
58 name: "no argument",
59 input: "",
60 output: EditOptions{
61 SelectorArg: "",
62 Interactive: true,
63 },
64 wantsErr: false,
65 },
66 {
67 name: "two arguments",
68 input: "1 2",
69 output: EditOptions{},
70 wantsErr: true,
71 },
72 {
73 name: "URL argument",
74 input: "https://example.com/cli/cli/pull/23",
75 output: EditOptions{
76 SelectorArg: "https://example.com/cli/cli/pull/23",
77 Interactive: true,
78 },
79 expectedBaseRepo: ghrepo.NewWithHost("cli", "cli", "example.com"),
80 wantsErr: false,
81 },
82 {
83 name: "pull request number argument",
84 input: "23",
85 output: EditOptions{
86 SelectorArg: "23",
87 Interactive: true,

Callers

nothing calls this directly

Calls 15

NewWithHostFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
JoinMethod · 0.80
WriteFileMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
EventsMethod · 0.80
NewCmdEditFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected