MCPcopy Create free account
hub / github.com/cli/cli / TestNewCmdView

Function TestNewCmdView

pkg/cmd/issue/artifact/view/view_test.go:40–267  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestNewCmdView(t *testing.T) {
41 tests := []struct {
42 name string
43 args string
44 ghRepo string
45 wantOpts ViewOptions
46 wantRepo string
47 wantErr string
48 wantFlagErr bool
49 }{
50 {
51 name: "an issue number and an artifact number",
52 args: "142 2",
53 wantOpts: ViewOptions{IssueNumber: 142, ArtifactNumber: 2},
54 wantRepo: "OWNER/REPO",
55 },
56 {
57 name: "an issue URL names the repository",
58 args: "https://github.com/monalisa/monas-cafe/issues/142 2",
59 wantOpts: ViewOptions{IssueNumber: 142, ArtifactNumber: 2},
60 wantRepo: "monalisa/monas-cafe",
61 },
62 {
63 name: "-R selects the repository",
64 args: "142 2 -R monalisa/monas-cafe",
65 wantOpts: ViewOptions{IssueNumber: 142, ArtifactNumber: 2},
66 wantRepo: "monalisa/monas-cafe",
67 },
68 {
69 name: "GH_REPO selects the repository",
70 args: "142 2",
71 ghRepo: "monalisa/monas-cafe",
72 wantOpts: ViewOptions{IssueNumber: 142, ArtifactNumber: 2},
73 wantRepo: "monalisa/monas-cafe",
74 },
75 {
76 name: "--version",
77 args: "142 2 --version 5",
78 wantOpts: ViewOptions{IssueNumber: 142, ArtifactNumber: 2, Version: 5},
79 wantRepo: "OWNER/REPO",
80 },
81 {
82 name: "--version 0",
83 args: "142 2 --version 0",
84 wantErr: "invalid version: 0",
85 wantFlagErr: true,
86 },
87 {
88 name: "a negative --version",
89 args: "142 2 --version -1",
90 wantErr: "invalid version: -1",
91 wantFlagErr: true,
92 },
93 {
94 name: "--version with --json",
95 args: "142 2 --version 5 --json body",
96 wantErr: "specify only one of `--version` or `--json`",
97 wantFlagErr: true,

Callers

nothing calls this directly

Calls 8

TestFunction · 0.92
NewFunction · 0.92
EnableRepoOverrideFunction · 0.92
FullNameFunction · 0.92
EqualMethod · 0.80
NewCmdViewFunction · 0.70
RunMethod · 0.65
BaseRepoMethod · 0.65

Tested by

no test coverage detected