@@ -345,6 +345,89 @@ func Test_viewRun(t *testing.T) {
345345 gh agent-task view 'some-session-id' --log
346346 ` ),
347347 },
348+ {
349+ name : "with session id, success, with zero premium requests (tty)" ,
350+ tty : true ,
351+ opts : ViewOptions {
352+ SelectorArg : "some-session-id" ,
353+ SessionID : "some-session-id" ,
354+ },
355+ capiStubs : func (t * testing.T , m * capi.CapiClientMock ) {
356+ m .GetSessionFunc = func (_ context.Context , id string ) (* capi.Session , error ) {
357+ assert .Equal (t , "some-session-id" , id )
358+ return & capi.Session {
359+ ID : "some-session-id" ,
360+ State : "completed" ,
361+ CreatedAt : sampleDate ,
362+ CompletedAt : sampleCompletedAt ,
363+ PremiumRequests : 0 ,
364+ PullRequest : & api.PullRequest {
365+ Title : "fix something" ,
366+ Number : 101 ,
367+ URL : "https://github.com/OWNER/REPO/pull/101" ,
368+ Repository : & api.PRRepository {
369+ NameWithOwner : "OWNER/REPO" ,
370+ },
371+ },
372+ User : & api.GitHubUser {
373+ Login : "octocat" ,
374+ },
375+ }, nil
376+ }
377+ },
378+ wantOut : heredoc .Doc (`
379+ Ready for review • fix something • OWNER/REPO#101
380+ Started on behalf of octocat about 6 hours ago
381+ Used 0 premium request(s) • Duration 5m0s
382+
383+ For detailed session logs, try:
384+ gh agent-task view 'some-session-id' --log
385+
386+ View this session on GitHub:
387+ https://github.com/OWNER/REPO/pull/101/agent-sessions/some-session-id
388+ ` ),
389+ },
390+ {
391+ name : "with session id, success, duration not available (tty)" ,
392+ tty : true ,
393+ opts : ViewOptions {
394+ SelectorArg : "some-session-id" ,
395+ SessionID : "some-session-id" ,
396+ },
397+ capiStubs : func (t * testing.T , m * capi.CapiClientMock ) {
398+ m .GetSessionFunc = func (_ context.Context , id string ) (* capi.Session , error ) {
399+ assert .Equal (t , "some-session-id" , id )
400+ return & capi.Session {
401+ ID : "some-session-id" ,
402+ State : "in_progress" ,
403+ CreatedAt : sampleDate ,
404+ PremiumRequests : 1.5 ,
405+ PullRequest : & api.PullRequest {
406+ Title : "fix something" ,
407+ Number : 101 ,
408+ URL : "https://github.com/OWNER/REPO/pull/101" ,
409+ Repository : & api.PRRepository {
410+ NameWithOwner : "OWNER/REPO" ,
411+ },
412+ },
413+ User : & api.GitHubUser {
414+ Login : "octocat" ,
415+ },
416+ }, nil
417+ }
418+ },
419+ wantOut : heredoc .Doc (`
420+ In progress • fix something • OWNER/REPO#101
421+ Started on behalf of octocat about 6 hours ago
422+ Used 1.5 premium request(s)
423+
424+ For detailed session logs, try:
425+ gh agent-task view 'some-session-id' --log
426+
427+ View this session on GitHub:
428+ https://github.com/OWNER/REPO/pull/101/agent-sessions/some-session-id
429+ ` ),
430+ },
348431 {
349432 name : "with session id, not found, web mode (tty)" ,
350433 tty : true ,
0 commit comments