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

Function TestNewCmdEdit

pkg/cmd/issue/artifact/edit/edit_test.go:35–452  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33)
34
35func TestNewCmdEdit(t *testing.T) {
36 attachEvent := func(count int64) []ghtelemetry.Event {
37 return []ghtelemetry.Event{{
38 Type: "attachment_invocation",
39 Dimensions: ghtelemetry.Dimensions{"command": "edit"},
40 Measures: ghtelemetry.Measures{
41 "attach_count": count, "append_ops_count": 0, "replace_ops_count": 0,
42 },
43 }}
44 }
45
46 tests := []struct {
47 name string
48 args string
49 ghRepo string
50 wantOpts EditOptions
51 wantAssetPaths []string
52 wantEvents []ghtelemetry.Event
53 wantRepo string
54 wantErr string
55 wantFlagErr bool
56 }{
57 {
58 name: "--name",
59 args: "142 2 --name 'OAuth callback plan v2'",
60 wantOpts: EditOptions{
61 IssueNumber: 142,
62 ArtifactNumber: 2,
63 Name: new("OAuth callback plan v2"),
64 },
65 wantRepo: "OWNER/REPO",
66 },
67 {
68 name: "a name of spaces is left to the server",
69 args: "142 2 --name ' '",
70 wantOpts: EditOptions{
71 IssueNumber: 142,
72 ArtifactNumber: 2,
73 Name: new(" "),
74 },
75 wantRepo: "OWNER/REPO",
76 },
77 {
78 name: "--body",
79 args: "142 3 --body " + runbookURLv2,
80 wantOpts: EditOptions{
81 IssueNumber: 142,
82 ArtifactNumber: 3,
83 Body: new(runbookURLv2),
84 },
85 wantRepo: "OWNER/REPO",
86 },
87 {
88 name: "-b is --body",
89 args: "142 2 -b '# OAuth callback plan'",
90 wantOpts: EditOptions{
91 IssueNumber: 142,
92 ArtifactNumber: 2,

Callers

nothing calls this directly

Calls 15

TestFunction · 0.92
NewFunction · 0.92
EnableRepoOverrideFunction · 0.92
FullNameFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
EventsMethod · 0.80
writeTestFileFunction · 0.70
NewCmdEditFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected