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

Function TestNewCmdCreate

pkg/cmd/pr/create/create_test.go:39–416  ·  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 attachmentEvent := []ghtelemetry.Event{{
48 Type: "attachment_invocation",
49 Dimensions: ghtelemetry.Dimensions{"command": "create"},
50 Measures: ghtelemetry.Measures{
51 "attach_count": 1, "append_ops_count": 0, "replace_ops_count": 0,
52 },
53 }}
54
55 tests := []struct {
56 name string
57 tty bool
58 stdin string
59 cli string
60 config string
61 wantsErr bool
62 wantsErrMsg string
63 // wantErrIsNotExist covers an error whose text the operating system
64 // words differently, so the assertion cannot be on the message.
65 wantErrIsNotExist bool
66 wantAssetPaths []string
67 wantsOpts CreateOptions
68 wantEvents []ghtelemetry.Event
69 wantSampleRate int
70 }{
71 {
72 name: "empty non-tty",
73 tty: false,
74 cli: "",
75 wantsErr: true,
76 },
77 {
78 name: "only title non-tty",
79 tty: false,
80 cli: "--title mytitle",
81 wantsErr: true,
82 },
83 {
84 name: "minimum non-tty",
85 tty: false,
86 cli: "--title mytitle --body ''",
87 wantsErr: false,
88 wantsOpts: CreateOptions{
89 Title: "mytitle",
90 TitleProvided: true,
91 Body: "",
92 BodyProvided: true,
93 Autofill: false,
94 RecoverFile: "",
95 WebMode: false,
96 IsDraft: false,

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected