github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/actor/v3action/process_test.go (about) 1 package v3action_test 2 3 import ( 4 "time" 5 6 . "code.cloudfoundry.org/cli/actor/v3action" 7 "code.cloudfoundry.org/cli/actor/v3action/v3actionfakes" 8 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Process Actions", func() { 14 var ( 15 actor *Actor 16 fakeCloudControllerClient *v3actionfakes.FakeCloudControllerClient 17 ) 18 19 BeforeEach(func() { 20 fakeCloudControllerClient = new(v3actionfakes.FakeCloudControllerClient) 21 actor = NewActor(fakeCloudControllerClient, nil) 22 }) 23 24 Describe("Instance", func() { 25 Describe("StartTime", func() { 26 It("returns the time that the instance started", func() { 27 instance := Instance{Uptime: 86400} 28 Expect(instance.StartTime()).To(BeTemporally("~", time.Now().Add(-24*time.Hour), 10*time.Second)) 29 }) 30 }) 31 }) 32 33 Describe("Process", func() { 34 var process Process 35 BeforeEach(func() { 36 process = Process{ 37 Instances: []Instance{ 38 Instance{State: "RUNNING"}, 39 Instance{State: "RUNNING"}, 40 Instance{State: "STOPPED"}, 41 }, 42 } 43 }) 44 45 Describe("TotalInstanceCount", func() { 46 It("returns the total number of instances", func() { 47 Expect(process.TotalInstanceCount()).To(Equal(3)) 48 }) 49 }) 50 51 Describe("HealthyInstanceCount", func() { 52 It("returns the total number of RUNNING instances", func() { 53 Expect(process.HealthyInstanceCount()).To(Equal(2)) 54 }) 55 }) 56 }) 57 })