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

Function TestParseFullReference

pkg/cmd/pr/shared/finder_test.go:115–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func TestParseFullReference(t *testing.T) {
116 tests := []struct {
117 name string
118 arg string
119 wantRepo ghrepo.Interface
120 wantNumber int
121 wantErr string
122 }{
123 {
124 name: "number",
125 arg: "123",
126 wantErr: `invalid reference: "123"`,
127 },
128 {
129 name: "number with hash",
130 arg: "#123",
131 wantErr: `invalid reference: "#123"`,
132 },
133 {
134 name: "full form",
135 arg: "OWNER/REPO#123",
136 wantNumber: 123,
137 wantRepo: ghrepo.New("OWNER", "REPO"),
138 },
139 {
140 name: "empty",
141 wantErr: "empty reference",
142 },
143 {
144 name: "invalid full form, without hash",
145 arg: "OWNER/REPO123",
146 wantErr: `invalid reference: "OWNER/REPO123"`,
147 },
148 {
149 name: "invalid full form, empty owner and repo",
150 arg: "/#123",
151 wantErr: `invalid reference: "/#123"`,
152 },
153 {
154 name: "invalid full form, without owner",
155 arg: "REPO#123",
156 wantErr: `invalid reference: "REPO#123"`,
157 },
158 {
159 name: "invalid full form, without repo",
160 arg: "OWNER/#123",
161 wantErr: `invalid reference: "OWNER/#123"`,
162 },
163 {
164 name: "invalid full form, too large number",
165 arg: "OWNER/REPO#9999999999999999999",
166 wantErr: `invalid reference: "OWNER/REPO#9999999999999999999"; strconv.Atoi: parsing "9999999999999999999": value out of range`,
167 },
168 }
169
170 for _, tt := range tests {
171 t.Run(tt.name, func(t *testing.T) {
172 repo, number, err := ParseFullReference(tt.arg)

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
IsSameFunction · 0.92
ParseFullReferenceFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected