MCPcopy
hub / github.com/cli/cli / TestNewCmdCreate

Function TestNewCmdCreate

pkg/cmd/agent-task/create/create_test.go:25–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestNewCmdCreate(t *testing.T) {
26 tests := []struct {
27 name string
28 args string
29 tty bool
30 wantOpts *CreateOptions
31 wantErr string
32 }{
33 {
34 name: "no args nor file returns no error (prompting path)",
35 tty: true,
36 wantOpts: &CreateOptions{
37 ProblemStatement: "",
38 ProblemStatementFile: "",
39 },
40 },
41 {
42 name: "arg only success",
43 args: "'task description from args'",
44 wantOpts: &CreateOptions{
45 ProblemStatement: "task description from args",
46 ProblemStatementFile: "",
47 },
48 },
49 {
50 name: "empty arg",
51 args: "''",
52 wantErr: "task description cannot be empty",
53 },
54 {
55 name: "whitespace arg",
56 args: "' '",
57 wantErr: "task description cannot be empty",
58 },
59 {
60 name: "whitespace and newline arg",
61 args: "'\n'",
62 wantErr: "task description cannot be empty",
63 },
64 {
65 name: "mutually exclusive arg and file",
66 args: "'some task inline' -F foo.md",
67 wantErr: "only one of -F or arg can be provided",
68 },
69 {
70 name: "base branch sets baseBranch field",
71 args: "'task description' -b feature",
72 wantOpts: &CreateOptions{
73 ProblemStatement: "task description",
74 ProblemStatementFile: "",
75 BaseBranch: "feature",
76 },
77 },
78 {
79 name: "with --follow",
80 args: "'task description from args' --follow",
81 wantOpts: &CreateOptions{
82 ProblemStatement: "task description from args",

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected