MCPcopy Index your code
hub / github.com/cli/cli / Test_NewCmdLock

Function Test_NewCmdLock

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

Source from the content-addressed store, hash-verified

18)
19
20func Test_NewCmdLock(t *testing.T) {
21 cases := []struct {
22 name string
23 args string
24 want LockOptions
25 wantErr string
26 tty bool
27 }{
28 {
29 name: "sets reason",
30 args: "--reason off_topic 451",
31 want: LockOptions{
32 Reason: "off_topic",
33 IssueNumber: 451,
34 },
35 },
36 {
37 name: "no args",
38 wantErr: "accepts 1 arg(s), received 0",
39 },
40 {
41 name: "no flags",
42 args: "451",
43 want: LockOptions{
44 IssueNumber: 451,
45 },
46 },
47 {
48 name: "issue number argument",
49 args: "451 --repo owner/repo",
50 want: LockOptions{
51 IssueNumber: 451,
52 },
53 },
54 {
55 name: "argument is hash prefixed number",
56 // Escaping is required here to avoid what I think is shellex treating it as a comment.
57 args: "\\#451 --repo owner/repo",
58 want: LockOptions{
59 IssueNumber: 451,
60 },
61 },
62 {
63 name: "argument is a URL",
64 args: "https://github.com/cli/cli/issues/451",
65 want: LockOptions{
66 IssueNumber: 451,
67 },
68 },
69 {
70 name: "argument cannot be parsed to an issue",
71 args: "unparseable",
72 wantErr: "invalid issue format: \"unparseable\"",
73 },
74 {
75 name: "bad reason",
76 args: "--reason bad 451",
77 wantErr: "invalid reason bad",

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected