MCPcopy
hub / github.com/cli/cli / TestParseDiscussionArg

Function TestParseDiscussionArg

pkg/cmd/discussion/shared/lookup_test.go:10–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestParseDiscussionArg(t *testing.T) {
11 tests := []struct {
12 name string
13 arg string
14 wantNum int32
15 wantOwner string
16 wantRepo string
17 wantHost string
18 wantErr string
19 }{
20 {
21 name: "empty",
22 arg: "",
23 wantErr: `invalid discussion argument: ""`,
24 },
25 {
26 name: "whitespaces",
27 arg: " ",
28 wantErr: `invalid discussion argument: " "`,
29 },
30 {
31 name: "invalid string",
32 arg: "not-a-number",
33 wantErr: `invalid discussion argument: "not-a-number"`,
34 },
35 {
36 name: "hash only",
37 arg: "#",
38 wantErr: `invalid discussion argument: "#"`,
39 },
40 {
41 name: "hash non-numeric",
42 arg: "#abc",
43 wantErr: `invalid discussion argument: "#abc"`,
44 },
45 {
46 name: "URL with wrong path",
47 arg: "https://github.com/owner/repo/issues/10",
48 wantErr: `invalid discussion URL: "https://github.com/owner/repo/issues/10"`,
49 },
50 {
51 name: "URL missing number",
52 arg: "https://github.com/owner/repo/discussions/",
53 wantErr: `invalid discussion URL: "https://github.com/owner/repo/discussions/"`,
54 },
55 {
56 name: "URL with overflowing number",
57 arg: "https://github.com/owner/repo/discussions/99999999999999999999",
58 wantErr: `invalid discussion number in URL: "99999999999999999999"`,
59 },
60 {
61 name: "zero",
62 arg: "0",
63 wantNum: 0,
64 },
65 {
66 name: "plain number",
67 arg: "42",

Callers

nothing calls this directly

Calls 7

ParseDiscussionArgFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RepoHostMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected