@@ -158,72 +158,85 @@ func Test_createRun(t *testing.T) {
158158 wantErrIs error
159159 }{
160160 {
161- name : "interactive with file prompts to edit with file contents" ,
161+ name : "interactive, problem statement from arg" ,
162+ isTTY : true ,
163+ opts : & CreateOptions {
164+ BaseRepo : func () (ghrepo.Interface , error ) { return ghrepo .New ("OWNER" , "REPO" ), nil },
165+ ProblemStatement : "task description from arg" ,
166+ },
167+ capiStubs : func (t * testing.T , m * capi.CapiClientMock ) {
168+ m .CreateJobFunc = func (ctx context.Context , owner , repo , problemStatement , baseBranch string ) (* capi.Job , error ) {
169+ require .Equal (t , "OWNER" , owner )
170+ require .Equal (t , "REPO" , repo )
171+ require .Equal (t , "task description from arg" , problemStatement )
172+ return & createdJobSuccessWithPR , nil
173+ }
174+ },
175+ wantStdout : "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n " ,
176+ },
177+ {
178+ name : "non-interactive, problem statement from arg" ,
179+ opts : & CreateOptions {
180+ BaseRepo : func () (ghrepo.Interface , error ) { return ghrepo .New ("OWNER" , "REPO" ), nil },
181+ ProblemStatement : "task description from arg" ,
182+ },
183+ capiStubs : func (t * testing.T , m * capi.CapiClientMock ) {
184+ m .CreateJobFunc = func (ctx context.Context , owner , repo , problemStatement , baseBranch string ) (* capi.Job , error ) {
185+ require .Equal (t , "OWNER" , owner )
186+ require .Equal (t , "REPO" , repo )
187+ require .Equal (t , "task description from arg" , problemStatement )
188+ return & createdJobSuccessWithPR , nil
189+ }
190+ },
191+ wantStdout : "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n " ,
192+ },
193+ {
194+ name : "interactive, problem statement from file" ,
195+ isTTY : true ,
162196 opts : & CreateOptions {
163197 BaseRepo : func () (ghrepo.Interface , error ) { return ghrepo .New ("OWNER" , "REPO" ), nil },
164198 ProblemStatement : "" ,
165199 ProblemStatementFile : taskDescFile ,
166- Prompter : & prompter.PrompterMock {
167- MarkdownEditorFunc : func (prompt , defaultValue string , blankAllowed bool ) (string , error ) {
168- require .Equal (t , "Enter the task description" , prompt )
169- require .Equal (t , "task description from file" , defaultValue )
170- return "edited task description" , nil
171- },
172- ConfirmFunc : func (message string , defaultValue bool ) (bool , error ) {
173- require .Equal (t , "Submit agent task" , message )
174- return true , nil
175- },
176- },
177200 },
178- isTTY : true ,
179201 capiStubs : func (t * testing.T , m * capi.CapiClientMock ) {
180202 m .CreateJobFunc = func (ctx context.Context , owner , repo , problemStatement , baseBranch string ) (* capi.Job , error ) {
181203 require .Equal (t , "OWNER" , owner )
182204 require .Equal (t , "REPO" , repo )
183- require .Equal (t , "edited task description" , problemStatement )
205+ require .Equal (t , "task description from file " , problemStatement )
184206 return & createdJobSuccessWithPR , nil
185207 }
186208 },
187209 wantStdout : "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n " ,
188210 },
189211 {
190- name : "interactively rejecting confirmation prompt aborts task creation " ,
212+ name : "non-interactive, problem statement loaded from file " ,
191213 opts : & CreateOptions {
192- BaseRepo : func () (ghrepo.Interface , error ) { return ghrepo .New ("OWNER" , "REPO" ), nil },
193- ProblemStatement : "" ,
194- Prompter : & prompter.PrompterMock {
195- MarkdownEditorFunc : func (prompt , defaultValue string , blankAllowed bool ) (string , error ) {
196- require .Equal (t , "Enter the task description" , prompt )
197- return "From editor" , nil
198- },
199- ConfirmFunc : func (message string , defaultValue bool ) (bool , error ) {
200- require .Equal (t , "Submit agent task" , message )
201- return false , nil
202- },
203- },
214+ BaseRepo : func () (ghrepo.Interface , error ) { return ghrepo .New ("OWNER" , "REPO" ), nil },
215+ ProblemStatement : "" ,
216+ ProblemStatementFile : taskDescFile ,
217+ },
218+ capiStubs : func (t * testing.T , m * capi.CapiClientMock ) {
219+ m .CreateJobFunc = func (ctx context.Context , owner , repo , problemStatement , baseBranch string ) (* capi.Job , error ) {
220+ require .Equal (t , "OWNER" , owner )
221+ require .Equal (t , "REPO" , repo )
222+ require .Equal (t , "task description from file" , problemStatement )
223+ return & createdJobSuccessWithPR , nil
224+ }
204225 },
205- isTTY : true ,
206- wantErr : "SilentError" ,
207- wantErrIs : cmdutil .SilentError ,
208- wantStdErr : "" ,
226+ wantStdout : "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n " ,
209227 },
210228 {
211- name : "interactively entering task description with editor, no file " ,
229+ name : "interactive, problem statement from prompt/ editor" ,
212230 isTTY : true ,
213231 opts : & CreateOptions {
214232 BaseRepo : func () (ghrepo.Interface , error ) {
215233 return ghrepo .New ("OWNER" , "REPO" ), nil
216234 },
217- ProblemStatement : "" ,
218235 Prompter : & prompter.PrompterMock {
219236 MarkdownEditorFunc : func (prompt , defaultValue string , blankAllowed bool ) (string , error ) {
220237 require .Equal (t , "Enter the task description" , prompt )
221238 return "From editor" , nil
222239 },
223- ConfirmFunc : func (message string , defaultValue bool ) (bool , error ) {
224- require .Equal (t , "Submit agent task" , message )
225- return true , nil
226- },
227240 },
228241 },
229242 capiStubs : func (t * testing.T , m * capi.CapiClientMock ) {
@@ -235,7 +248,7 @@ func Test_createRun(t *testing.T) {
235248 wantStdout : "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n " ,
236249 },
237250 {
238- name : "empty task description from interactive prompt returns error" ,
251+ name : "interactive, empty task description from editor returns error" ,
239252 isTTY : true ,
240253 opts : & CreateOptions {
241254 BaseRepo : func () (ghrepo.Interface , error ) {
@@ -247,26 +260,7 @@ func Test_createRun(t *testing.T) {
247260 },
248261 },
249262 },
250- wantErr : "SilentError" ,
251- wantErrIs : cmdutil .SilentError ,
252- wantStdErr : "a task description is required.\n " ,
253- },
254- {
255- name : "problem statement loaded from file non-interactively doesn't prompt or return error" ,
256- opts : & CreateOptions {
257- BaseRepo : func () (ghrepo.Interface , error ) { return ghrepo .New ("OWNER" , "REPO" ), nil },
258- ProblemStatement : "" ,
259- ProblemStatementFile : taskDescFile ,
260- },
261- capiStubs : func (t * testing.T , m * capi.CapiClientMock ) {
262- m .CreateJobFunc = func (ctx context.Context , owner , repo , problemStatement , baseBranch string ) (* capi.Job , error ) {
263- require .Equal (t , "OWNER" , owner )
264- require .Equal (t , "REPO" , repo )
265- require .Equal (t , "task description from file" , problemStatement )
266- return & createdJobSuccessWithPR , nil
267- }
268- },
269- wantStdout : "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n " ,
263+ wantErr : "a task description is required" ,
270264 },
271265 {
272266 name : "missing repo returns error" ,
@@ -276,18 +270,6 @@ func Test_createRun(t *testing.T) {
276270 }},
277271 wantErr : "a repository is required; re-run in a repository or supply one with --repo owner/name" ,
278272 },
279- {
280- name : "non-interactive empty description returns error" ,
281- opts : & CreateOptions {
282- BaseRepo : func () (ghrepo.Interface , error ) {
283- return ghrepo .New ("OWNER" , "REPO" ), nil
284- },
285- ProblemStatement : "" ,
286- },
287- wantErr : "SilentError" ,
288- wantErrIs : cmdutil .SilentError ,
289- wantStdErr : "a task description is required.\n " ,
290- },
291273 {
292274 name : "problem statement loaded from arg non-interactively doesn't prompt or return error" ,
293275 opts : & CreateOptions {
0 commit comments