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

Function TestNewCmdCheckout

pkg/cmd/pr/checkout/checkout_test.go:29–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestNewCmdCheckout(t *testing.T) {
30 tests := []struct {
31 name string
32 args string
33 wantsOpts CheckoutOptions
34 wantErr error
35 }{
36 {
37 name: "recurse submodules",
38 args: "--recurse-submodules 123",
39 wantsOpts: CheckoutOptions{
40 RecurseSubmodules: true,
41 },
42 },
43 {
44 name: "force",
45 args: "--force 123",
46 wantsOpts: CheckoutOptions{
47 Force: true,
48 },
49 },
50 {
51 name: "detach",
52 args: "--detach 123",
53 wantsOpts: CheckoutOptions{
54 Detach: true,
55 },
56 },
57 {
58 name: "branch",
59 args: "--branch test-branch 123",
60 wantsOpts: CheckoutOptions{
61 BranchName: "test-branch",
62 },
63 },
64 {
65 name: "worktree",
66 args: "--worktree /path/to/wt 123",
67 wantsOpts: CheckoutOptions{
68 Worktree: "/path/to/wt",
69 },
70 },
71 {
72 name: "when --worktree is given a blank path, returns an error",
73 args: `--worktree "" 123`,
74 wantErr: cmdutil.FlagErrorf("--worktree cannot be blank"),
75 },
76 {
77 name: "when there is no selector and no TTY, returns an error",
78 args: "",
79 wantErr: cmdutil.FlagErrorf("pull request number, URL, or branch required when not running interactively"),
80 },
81 }
82
83 for _, tt := range tests {
84 t.Run(tt.name, func(t *testing.T) {
85 ios, _, _, _ := iostreams.Test()
86 f := &cmdutil.Factory{

Callers

nothing calls this directly

Calls 6

FlagErrorfFunction · 0.92
TestFunction · 0.92
NewCmdCheckoutFunction · 0.85
SetStdinTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected