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

Function TestNewCmdCreate

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

TestFunction · 0.92
NewMockConfigFromStringFunction · 0.92
NewMockConfigFunction · 0.92
JoinMethod · 0.80
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
ChangedMethod · 0.80
EqualMethod · 0.80
EmptyMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected