MCPcopy Index your code
hub / github.com/cli/cli / TestNewCmdCreate

Function TestNewCmdCreate

pkg/cmd/pr/create/create_test.go:33–331  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestNewCmdCreate(t *testing.T) {
34 tmpFile := filepath.Join(t.TempDir(), "my-body.md")
35 err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
36 require.NoError(t, err)
37
38 tests := []struct {
39 name string
40 tty bool
41 stdin string
42 cli string
43 config string
44 wantsErr bool
45 wantsOpts CreateOptions
46 }{
47 {
48 name: "empty non-tty",
49 tty: false,
50 cli: "",
51 wantsErr: true,
52 },
53 {
54 name: "only title non-tty",
55 tty: false,
56 cli: "--title mytitle",
57 wantsErr: true,
58 },
59 {
60 name: "minimum non-tty",
61 tty: false,
62 cli: "--title mytitle --body ''",
63 wantsErr: false,
64 wantsOpts: CreateOptions{
65 Title: "mytitle",
66 TitleProvided: true,
67 Body: "",
68 BodyProvided: true,
69 Autofill: false,
70 RecoverFile: "",
71 WebMode: false,
72 IsDraft: false,
73 BaseBranch: "",
74 HeadBranch: "",
75 MaintainerCanModify: true,
76 },
77 },
78 {
79 name: "empty tty",
80 tty: true,
81 cli: "",
82 wantsErr: false,
83 wantsOpts: CreateOptions{
84 Title: "",
85 TitleProvided: false,
86 Body: "",
87 BodyProvided: false,
88 Autofill: false,
89 RecoverFile: "",
90 WebMode: false,

Callers

nothing calls this directly

Calls 11

TestFunction · 0.92
NewFromStringFunction · 0.92
NewBlankConfigFunction · 0.92
JoinMethod · 0.80
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected