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

Function TestNewCmdCreate

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

Source from the content-addressed store, hash-verified

35)
36
37func TestNewCmdCreate(t *testing.T) {
38 tmpFile := filepath.Join(t.TempDir(), "my-body.md")
39 err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
40 require.NoError(t, err)
41
42 tmpImage := filepath.Join(t.TempDir(), "shot.png")
43 require.NoError(t, os.WriteFile(tmpImage, []byte("the bytes"), 0600))
44
45 tests := []struct {
46 name string
47 tty bool
48 stdin string
49 cli string
50 config string
51 wantsErr bool
52 wantsErrMsg string
53 // wantErrIsNotExist covers an error whose text the operating system
54 // words differently, so the assertion cannot be on the message.
55 wantErrIsNotExist bool
56 wantAssetPaths []string
57 wantsOpts CreateOptions
58 }{
59 {
60 name: "empty non-tty",
61 tty: false,
62 cli: "",
63 wantsErr: true,
64 },
65 {
66 name: "only title non-tty",
67 tty: false,
68 cli: "--title mytitle",
69 wantsErr: true,
70 },
71 {
72 name: "minimum non-tty",
73 tty: false,
74 cli: "--title mytitle --body ''",
75 wantsErr: false,
76 wantsOpts: CreateOptions{
77 Title: "mytitle",
78 TitleProvided: true,
79 Body: "",
80 BodyProvided: true,
81 Autofill: false,
82 RecoverFile: "",
83 WebMode: false,
84 IsDraft: false,
85 BaseBranch: "",
86 HeadBranch: "",
87 MaintainerCanModify: true,
88 },
89 },
90 {
91 name: "empty tty",
92 tty: true,
93 cli: "",
94 wantsErr: false,

Callers

nothing calls this directly

Calls 12

TestFunction · 0.92
NewMockConfigFromStringFunction · 0.92
NewMockConfigFunction · 0.92
JoinMethod · 0.80
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65
PathMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected