MCPcopy
hub / github.com/cli/cli / Test_NewCmdUnlock

Function Test_NewCmdUnlock

pkg/cmd/issue/lock/lock_test.go:135–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

133}
134
135func Test_NewCmdUnlock(t *testing.T) {
136 cases := []struct {
137 name string
138 args string
139 want LockOptions
140 wantErr string
141 tty bool
142 }{
143 {
144 name: "no args",
145 wantErr: "accepts 1 arg(s), received 0",
146 },
147 {
148 name: "no flags",
149 args: "451",
150 want: LockOptions{
151 IssueNumber: 451,
152 },
153 },
154 {
155 name: "issue number argument",
156 args: "451 --repo owner/repo",
157 want: LockOptions{
158 IssueNumber: 451,
159 },
160 },
161 {
162 name: "argument is hash prefixed number",
163 // Escaping is required here to avoid what I think is shellex treating it as a comment.
164 args: "\\#451 --repo owner/repo",
165 want: LockOptions{
166 IssueNumber: 451,
167 },
168 },
169 {
170 name: "argument is a URL",
171 args: "https://github.com/cli/cli/issues/451",
172 want: LockOptions{
173 IssueNumber: 451,
174 },
175 },
176 {
177 name: "argument cannot be parsed to an issue",
178 args: "unparseable",
179 wantErr: "invalid issue format: \"unparseable\"",
180 },
181 }
182
183 for _, tt := range cases {
184 t.Run(tt.name, func(t *testing.T) {
185 ios, _, _, _ := iostreams.Test()
186 ios.SetStdoutTTY(tt.tty)
187 ios.SetStdinTTY(tt.tty)
188 ios.SetStderrTTY(tt.tty)
189 f := &cmdutil.Factory{
190 IOStreams: ios,
191 }
192 var opts *LockOptions

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
NewCmdUnlockFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected