MCPcopy
hub / github.com/cli/cli / TestNewCmdView

Function TestNewCmdView

pkg/cmd/discussion/view/view_test.go:47–278  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func TestNewCmdView(t *testing.T) {
48 tests := []struct {
49 name string
50 args string
51 wantErr string
52 wantOpts ViewOptions
53 wantRepo string
54 }{
55 {
56 name: "number argument",
57 args: "123",
58 wantOpts: ViewOptions{
59 DiscussionNumber: 123,
60 Limit: 30,
61 Order: "newest",
62 },
63 },
64 {
65 name: "hash number argument",
66 args: "'#456'",
67 wantOpts: ViewOptions{
68 DiscussionNumber: 456,
69 Limit: 30,
70 Order: "newest",
71 },
72 },
73 {
74 name: "URL argument",
75 args: "https://github.com/OTHER/REPO/discussions/789",
76 wantOpts: ViewOptions{
77 DiscussionNumber: 789,
78 Limit: 30,
79 Order: "newest",
80 },
81 wantRepo: "OTHER/REPO",
82 },
83 {
84 name: "invalid argument",
85 args: "not-a-number",
86 wantErr: "invalid argument",
87 },
88 {
89 name: "no arguments",
90 args: "",
91 wantErr: "accepts 1 arg(s), received 0",
92 },
93 {
94 name: "web flag",
95 args: "123 --web",
96 wantOpts: ViewOptions{
97 DiscussionNumber: 123,
98 WebMode: true,
99 Limit: 30,
100 Order: "newest",
101 },
102 },
103 {
104 name: "comments flag",

Callers

nothing calls this directly

Calls 9

TestFunction · 0.92
NewFunction · 0.92
FullNameFunction · 0.92
ContainsMethod · 0.80
EqualMethod · 0.80
NewCmdViewFunction · 0.70
RunMethod · 0.65
BaseRepoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected