fix(agent-task create): block empty problem statement arg
Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
parent
c7a811e567
commit
863329b4c1
2 changed files with 19 additions and 1 deletions
|
|
@ -70,6 +70,9 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
|
||||||
// Populate ProblemStatement from arg
|
// Populate ProblemStatement from arg
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
opts.ProblemStatement = args[0]
|
opts.ProblemStatement = args[0]
|
||||||
|
if strings.TrimSpace(opts.ProblemStatement) == "" {
|
||||||
|
return cmdutil.FlagErrorf("task description cannot be empty")
|
||||||
|
}
|
||||||
} else if opts.ProblemStatementFile == "" && !opts.IO.CanPrompt() {
|
} else if opts.ProblemStatementFile == "" && !opts.IO.CanPrompt() {
|
||||||
return cmdutil.FlagErrorf("a task description or -F is required when running non-interactively")
|
return cmdutil.FlagErrorf("a task description or -F is required when running non-interactively")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,21 @@ func TestNewCmdCreate(t *testing.T) {
|
||||||
ProblemStatementFile: "",
|
ProblemStatementFile: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "empty arg",
|
||||||
|
args: "''",
|
||||||
|
wantErr: "task description cannot be empty",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "whitespace arg",
|
||||||
|
args: "' '",
|
||||||
|
wantErr: "task description cannot be empty",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "whitespace and newline arg",
|
||||||
|
args: "'\n'",
|
||||||
|
wantErr: "task description cannot be empty",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "mutually exclusive arg and file",
|
name: "mutually exclusive arg and file",
|
||||||
args: "'some task inline' -F foo.md",
|
args: "'some task inline' -F foo.md",
|
||||||
|
|
@ -96,7 +111,7 @@ func TestNewCmdCreate(t *testing.T) {
|
||||||
|
|
||||||
_, err = cmd.ExecuteC()
|
_, err = cmd.ExecuteC()
|
||||||
if tt.wantErr != "" {
|
if tt.wantErr != "" {
|
||||||
require.Error(t, err, tt.wantErr)
|
require.EqualError(t, err, tt.wantErr)
|
||||||
} else {
|
} else {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue