@@ -518,10 +518,10 @@ var _ = Describe("RuncJobLifecycle", func() {
518518 bpmJobs , err := runcLifecycle .ListProcesses ()
519519 Expect (err ).NotTo (HaveOccurred ())
520520
521- Expect (bpmJobs ).To (ConsistOf ([]models.Process {
521+ Expect (bpmJobs ).To (ConsistOf ([]* models.Process {
522522 {Name : "job-process-2" , Pid : 23456 , Status : "created" },
523523 {Name : "job-process-1" , Pid : 34567 , Status : "running" },
524- {Name : "job-process-3" , Pid : 0 , Status : "stopped " },
524+ {Name : "job-process-3" , Pid : 0 , Status : "failed " },
525525 }))
526526 })
527527
@@ -542,18 +542,33 @@ var _ = Describe("RuncJobLifecycle", func() {
542542 })
543543
544544 It ("fetches the container state and translates it into a job" , func () {
545- job , err := runcLifecycle .GetProcess (bpmCfg )
545+ process , err := runcLifecycle .GetProcess (bpmCfg )
546546 Expect (err ).NotTo (HaveOccurred ())
547547 Expect (fakeRuncClient .ContainerStateCallCount ()).To (Equal (1 ))
548548 Expect (fakeRuncClient .ContainerStateArgsForCall (0 )).To (Equal (expectedContainerID ))
549- Expect (job ).NotTo (BeNil ())
550- Expect (* job ).To (Equal (models.Process {
549+ Expect (process ).To (Equal (& models.Process {
551550 Name : expectedContainerID ,
552551 Pid : 1234 ,
553552 Status : "running" ,
554553 }))
555554 })
556555
556+ Context ("when the container state is stopped" , func () {
557+ BeforeEach (func () {
558+ fakeRuncClient .ContainerStateReturns (& specs.State {ID : expectedContainerID , Pid : 0 , Status : "stopped" }, nil )
559+ })
560+
561+ It ("fetches the container state and translates it into a job" , func () {
562+ process , err := runcLifecycle .GetProcess (bpmCfg )
563+ Expect (err ).NotTo (HaveOccurred ())
564+ Expect (process ).To (Equal (& models.Process {
565+ Name : expectedContainerID ,
566+ Pid : 0 ,
567+ Status : "failed" ,
568+ }))
569+ })
570+ })
571+
557572 Context ("when the process name is the same as the job name" , func () {
558573 BeforeEach (func () {
559574 bpmCfg = config .NewBPMConfig (expectedSystemRoot , expectedJobName , expectedJobName )
@@ -574,10 +589,10 @@ var _ = Describe("RuncJobLifecycle", func() {
574589 })
575590
576591 It ("returns nil,nil" , func () {
577- job , err := runcLifecycle .GetProcess (bpmCfg )
592+ process , err := runcLifecycle .GetProcess (bpmCfg )
578593 Expect (err ).NotTo (HaveOccurred ())
579594
580- Expect (job ).To (BeNil ())
595+ Expect (process ).To (BeNil ())
581596 })
582597 })
583598
0 commit comments