github.com/cloudfoundry-attic/ltc@v0.0.0-20151123212628-098adc7919fc/app_examiner/command_factory/presentation/presentation_test.go (about) 1 package presentation_test 2 3 import ( 4 . "github.com/onsi/ginkgo" 5 . "github.com/onsi/gomega" 6 7 "github.com/cloudfoundry-incubator/ltc/app_examiner" 8 "github.com/cloudfoundry-incubator/ltc/app_examiner/command_factory/presentation" 9 "github.com/cloudfoundry-incubator/ltc/terminal/colors" 10 "github.com/cloudfoundry-incubator/receptor" 11 ) 12 13 var _ = Describe("Presentation", func() { 14 Describe("ColorInstanceState", func() { 15 It("colors RUNNING green", func() { 16 instanceInfo := app_examiner.InstanceInfo{State: string(receptor.ActualLRPStateRunning)} 17 Expect(presentation.ColorInstanceState(instanceInfo)).To(Equal(colors.Green(string(receptor.ActualLRPStateRunning)))) 18 }) 19 20 It("colors CLAIMED yellow", func() { 21 instanceInfo := app_examiner.InstanceInfo{State: string(receptor.ActualLRPStateClaimed)} 22 Expect(presentation.ColorInstanceState(instanceInfo)).To(Equal(colors.Yellow(string(receptor.ActualLRPStateClaimed)))) 23 }) 24 25 Context("when there is a placement error", func() { 26 It("colors UNCLAIMED red", func() { 27 instanceInfo := app_examiner.InstanceInfo{ 28 State: string(receptor.ActualLRPStateUnclaimed), 29 PlacementError: "I misplaced my cells. Uh oh.", 30 } 31 32 Expect(presentation.ColorInstanceState(instanceInfo)).To(Equal(colors.Red(string(receptor.ActualLRPStateUnclaimed)))) 33 }) 34 }) 35 36 Context("when there is not a placement error", func() { 37 It("colors UNCLAIMED cyan", func() { 38 instanceInfo := app_examiner.InstanceInfo{State: string(receptor.ActualLRPStateUnclaimed)} 39 Expect(presentation.ColorInstanceState(instanceInfo)).To(Equal(colors.Cyan(string(receptor.ActualLRPStateUnclaimed)))) 40 }) 41 }) 42 43 It("colors INVALID red", func() { 44 instanceInfo := app_examiner.InstanceInfo{State: string(receptor.ActualLRPStateInvalid)} 45 Expect(presentation.ColorInstanceState(instanceInfo)).To(Equal(colors.Red(string(receptor.ActualLRPStateInvalid)))) 46 }) 47 48 It("colors CRASHED red", func() { 49 instanceInfo := app_examiner.InstanceInfo{State: string(receptor.ActualLRPStateCrashed)} 50 Expect(presentation.ColorInstanceState(instanceInfo)).To(Equal(colors.Red(string(receptor.ActualLRPStateCrashed)))) 51 }) 52 }) 53 54 Describe("PadAndColorInstanceState", func() { 55 It("pads and colors States shorter than UNCLAIMED", func() { 56 instanceInfo := app_examiner.InstanceInfo{State: string(receptor.ActualLRPStateRunning)} 57 Expect(presentation.PadAndColorInstanceState(instanceInfo)).To(Equal(colors.Green(string(receptor.ActualLRPStateRunning)) + " ")) 58 }) 59 60 It("does not pad UNCLAIMED state", func() { 61 instanceInfo := app_examiner.InstanceInfo{State: string(receptor.ActualLRPStateUnclaimed)} 62 Expect(presentation.PadAndColorInstanceState(instanceInfo)).To(Equal(colors.Cyan(string(receptor.ActualLRPStateUnclaimed)))) 63 }) 64 }) 65 })