** LEGACY TESTS **/
(rt http.RoundTripper, remotes context.Remotes, branch string, cli string, baseRepo ghrepo.Interface)
| 461 | /** LEGACY TESTS **/ |
| 462 | |
| 463 | func runCommand(rt http.RoundTripper, remotes context.Remotes, branch string, cli string, baseRepo ghrepo.Interface) (*test.CmdOut, error) { |
| 464 | ios, _, stdout, stderr := iostreams.Test() |
| 465 | |
| 466 | factory := &cmdutil.Factory{ |
| 467 | IOStreams: ios, |
| 468 | HttpClient: func() (*http.Client, error) { |
| 469 | return &http.Client{Transport: rt}, nil |
| 470 | }, |
| 471 | Config: func() (gh.Config, error) { |
| 472 | return config.NewBlankConfig(), nil |
| 473 | }, |
| 474 | Remotes: func() (context.Remotes, error) { |
| 475 | if remotes == nil { |
| 476 | return context.Remotes{ |
| 477 | { |
| 478 | Remote: &git.Remote{Name: "origin"}, |
| 479 | Repo: ghrepo.New("OWNER", "REPO"), |
| 480 | }, |
| 481 | }, nil |
| 482 | } |
| 483 | return remotes, nil |
| 484 | }, |
| 485 | Branch: func() (string, error) { |
| 486 | return branch, nil |
| 487 | }, |
| 488 | GitClient: &git.Client{ |
| 489 | GhPath: "some/path/gh", |
| 490 | GitPath: "some/path/git", |
| 491 | }, |
| 492 | BaseRepo: func() (ghrepo.Interface, error) { |
| 493 | return baseRepo, nil |
| 494 | }, |
| 495 | } |
| 496 | |
| 497 | cmd := NewCmdCheckout(factory, nil) |
| 498 | |
| 499 | argv, err := shlex.Split(cli) |
| 500 | if err != nil { |
| 501 | return nil, err |
| 502 | } |
| 503 | cmd.SetArgs(argv) |
| 504 | |
| 505 | cmd.SetIn(&bytes.Buffer{}) |
| 506 | cmd.SetOut(io.Discard) |
| 507 | cmd.SetErr(io.Discard) |
| 508 | |
| 509 | _, err = cmd.ExecuteC() |
| 510 | return &test.CmdOut{ |
| 511 | OutBuf: stdout, |
| 512 | ErrBuf: stderr, |
| 513 | }, err |
| 514 | } |
| 515 | |
| 516 | func TestPRCheckout_sameRepo(t *testing.T) { |
| 517 | http := &httpmock.Registry{} |
no test coverage detected