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

Function runCommand

pkg/cmd/pr/checkout/checkout_test.go:858–909  ·  view source on GitHub ↗

** LEGACY TESTS **/

(rt http.RoundTripper, remotes context.Remotes, branch string, cli string, baseRepo ghrepo.Interface)

Source from the content-addressed store, hash-verified

856/** LEGACY TESTS **/
857
858func runCommand(rt http.RoundTripper, remotes context.Remotes, branch string, cli string, baseRepo ghrepo.Interface) (*test.CmdOut, error) {
859 ios, _, stdout, stderr := iostreams.Test()
860
861 factory := &cmdutil.Factory{
862 IOStreams: ios,
863 HttpClient: func() (*http.Client, error) {
864 return &http.Client{Transport: rt}, nil
865 },
866 Config: func() (gh.Config, error) {
867 return config.NewMockConfig(), nil
868 },
869 Remotes: func() (context.Remotes, error) {
870 if remotes == nil {
871 return context.Remotes{
872 {
873 Remote: &git.Remote{Name: "origin"},
874 Repo: ghrepo.New("OWNER", "REPO"),
875 },
876 }, nil
877 }
878 return remotes, nil
879 },
880 Branch: func() (string, error) {
881 return branch, nil
882 },
883 GitClient: &git.Client{
884 GhPath: "some/path/gh",
885 GitPath: "some/path/git",
886 },
887 BaseRepo: func() (ghrepo.Interface, error) {
888 return baseRepo, nil
889 },
890 }
891
892 cmd := NewCmdCheckout(factory, nil)
893
894 argv, err := shlex.Split(cli)
895 if err != nil {
896 return nil, err
897 }
898 cmd.SetArgs(argv)
899
900 cmd.SetIn(&bytes.Buffer{})
901 cmd.SetOut(io.Discard)
902 cmd.SetErr(io.Discard)
903
904 _, err = cmd.ExecuteC()
905 return &test.CmdOut{
906 OutBuf: stdout,
907 ErrBuf: stderr,
908 }, err
909}
910
911func TestPRCheckout_sameRepo(t *testing.T) {
912 http := &httpmock.Registry{}

Calls 4

TestFunction · 0.92
NewMockConfigFunction · 0.92
NewFunction · 0.92
NewCmdCheckoutFunction · 0.85

Tested by

no test coverage detected