MCPcopy
hub / github.com/cli/cli / TestNewCmdEdit

Function TestNewCmdEdit

pkg/cmd/discussion/edit/edit_test.go:20–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestNewCmdEdit(t *testing.T) {
21 tests := []struct {
22 name string
23 args string
24 isTTY bool
25 wantOpts EditOptions
26 wantBaseRepo ghrepo.Interface
27 wantErr string
28 }{
29 {
30 name: "all flags",
31 args: "123 --title 'New title' --body 'New body' --category 'Ideas'",
32 isTTY: true,
33 wantOpts: EditOptions{
34 DiscussionNumber: 123,
35 TitleProvided: true,
36 Title: "New title",
37 BodyProvided: true,
38 Body: "New body",
39 CategoryProvided: true,
40 Category: "Ideas",
41 },
42 },
43 {
44 name: "url arg overrides base repo",
45 args: "https://github.com/OWNER2/REPO2/discussions/42",
46 isTTY: true,
47 wantOpts: EditOptions{
48 DiscussionNumber: 42,
49 Interactive: true,
50 },
51 wantBaseRepo: ghrepo.New("OWNER2", "REPO2"),
52 },
53 {
54 name: "interactive mode when no flags and tty",
55 args: "123",
56 isTTY: true,
57 wantOpts: EditOptions{
58 DiscussionNumber: 123,
59 Interactive: true,
60 },
61 },
62 {
63 name: "labels flags",
64 args: "123 --add-label 'bug,help wanted' --remove-label stale",
65 isTTY: true,
66 wantOpts: EditOptions{
67 DiscussionNumber: 123,
68 AddLabels: []string{"bug", "help wanted"},
69 RemoveLabels: []string{"stale"},
70 LabelsProvided: true,
71 },
72 },
73 {
74 name: "mutual exclusion --body and --body-file",
75 args: "123 --body 'inline' --body-file body.md",
76 isTTY: true,
77 wantErr: "specify only one of --body or --body-file",

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
ContainsMethod · 0.80
EqualMethod · 0.80
NewCmdEditFunction · 0.70
RunMethod · 0.65
BaseRepoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected