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

Function TestNewCmdClose

pkg/cmd/issue/close/close_test.go:18–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestNewCmdClose(t *testing.T) {
19 // Test shared parsing of issue number / URL.
20 argparsetest.TestArgParsing(t, NewCmdClose)
21
22 tests := []struct {
23 name string
24 input string
25 output CloseOptions
26 expectedBaseRepo ghrepo.Interface
27 wantErr bool
28 errMsg string
29 }{
30 {
31 name: "comment",
32 input: "123 --comment 'closing comment'",
33 output: CloseOptions{
34 IssueNumber: 123,
35 Comment: "closing comment",
36 },
37 },
38 {
39 name: "reason",
40 input: "123 --reason 'not planned'",
41 output: CloseOptions{
42 IssueNumber: 123,
43 Reason: "not planned",
44 },
45 },
46 {
47 name: "reason duplicate",
48 input: "123 --reason duplicate",
49 output: CloseOptions{
50 IssueNumber: 123,
51 Reason: "duplicate",
52 },
53 },
54 {
55 name: "duplicate of sets duplicate reason",
56 input: "123 --duplicate-of 456",
57 output: CloseOptions{
58 IssueNumber: 123,
59 Reason: "duplicate",
60 DuplicateOf: "456",
61 },
62 },
63 {
64 name: "duplicate of with invalid reason",
65 input: "123 --reason completed --duplicate-of 456",
66 wantErr: true,
67 errMsg: "`--duplicate-of` can only be used with `--reason duplicate`",
68 },
69 }
70 for _, tt := range tests {
71 t.Run(tt.name, func(t *testing.T) {
72 ios, _, _, _ := iostreams.Test()
73 f := &cmdutil.Factory{
74 IOStreams: ios,
75 }

Callers

nothing calls this directly

Calls 8

TestArgParsingFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
EqualMethod · 0.80
NewCmdCloseFunction · 0.70
RunMethod · 0.65
BaseRepoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected