MCPcopy
hub / github.com/cli/cli / TestFind

Function TestFind

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

Source from the content-addressed store, hash-verified

203}
204
205func TestFind(t *testing.T) {
206 originOwnerUrl, err := url.Parse("https://github.com/ORIGINOWNER/REPO.git")
207 if err != nil {
208 t.Fatal(err)
209 }
210 remoteOrigin := ghContext.Remote{
211 Remote: &git.Remote{
212 Name: "origin",
213 FetchURL: originOwnerUrl,
214 },
215 Repo: ghrepo.New("ORIGINOWNER", "REPO"),
216 }
217 remoteOther := ghContext.Remote{
218 Remote: &git.Remote{
219 Name: "other",
220 FetchURL: originOwnerUrl,
221 },
222 Repo: ghrepo.New("ORIGINOWNER", "OTHER-REPO"),
223 }
224
225 upstreamOwnerUrl, err := url.Parse("https://github.com/UPSTREAMOWNER/REPO.git")
226 if err != nil {
227 t.Fatal(err)
228 }
229 remoteUpstream := ghContext.Remote{
230 Remote: &git.Remote{
231 Name: "upstream",
232 FetchURL: upstreamOwnerUrl,
233 },
234 Repo: ghrepo.New("UPSTREAMOWNER", "REPO"),
235 }
236
237 tests := []struct {
238 name string
239 args args
240 httpStub func(*httpmock.Registry)
241 wantUseProgress bool
242 wantPR int
243 wantRepo string
244 wantErr bool
245 }{
246 {
247 name: "number argument",
248 args: args{
249 selector: "13",
250 fields: []string{"id", "number"},
251 baseRepoFn: stubBaseRepoFn(ghrepo.New("ORIGINOWNER", "REPO"), nil),
252 branchFn: func() (string, error) {
253 return "blueberries", nil
254 },
255 },
256 httpStub: func(r *httpmock.Registry) {
257 r.Register(
258 httpmock.GraphQL(`query PullRequestByNumber\b`),
259 httpmock.StringResponse(`{"data":{"repository":{
260 "pullRequest":{"number":13}
261 }}}`))
262 },

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
FindMethod · 0.95
NewFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
FromFullNameFunction · 0.92
GraphQLQueryFunction · 0.92
GenerateRepoURLFunction · 0.92
stubBaseRepoFnFunction · 0.85
stubBranchConfigFunction · 0.85
stubPushDefaultFunction · 0.85
stubRemotePushDefaultFunction · 0.85

Tested by

no test coverage detected