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

Function TestNewCmdEdit

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