github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/actor/v7pushaction/v7pushaction_suite_test.go (about) 1 package v7pushaction_test 2 3 import ( 4 "os" 5 "time" 6 7 "testing" 8 9 . "code.cloudfoundry.org/cli/actor/v7pushaction" 10 "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" 11 . "github.com/onsi/ginkgo" 12 . "github.com/onsi/gomega" 13 14 log "github.com/sirupsen/logrus" 15 ) 16 17 func TestPushAction(t *testing.T) { 18 RegisterFailHandler(Fail) 19 RunSpecs(t, "V7 Push Actions Suite") 20 } 21 22 var _ = BeforeEach(func() { 23 SetDefaultEventuallyTimeout(3 * time.Second) 24 log.SetLevel(log.PanicLevel) 25 }) 26 27 func getCurrentDir() string { 28 pwd, err := os.Getwd() 29 Expect(err).NotTo(HaveOccurred()) 30 return pwd 31 } 32 33 func getTestPushActor() (*Actor, *v7pushactionfakes.FakeV7Actor, *v7pushactionfakes.FakeSharedActor) { 34 fakeV7Actor := new(v7pushactionfakes.FakeV7Actor) 35 fakeSharedActor := new(v7pushactionfakes.FakeSharedActor) 36 actor := NewActor(fakeV7Actor, fakeSharedActor) 37 return actor, fakeV7Actor, fakeSharedActor 38 } 39 40 func EventFollower(wrapper func(eventStream chan<- *PushEvent)) []Event { 41 eventStream := make(chan *PushEvent) 42 closed := make(chan bool) 43 44 var events []Event 45 46 go func() { 47 for { 48 event, ok := <-eventStream 49 if !ok { 50 close(closed) 51 return 52 } 53 events = append(events, event.Event) 54 } 55 }() 56 57 wrapper(eventStream) 58 close(eventStream) 59 60 <-closed 61 return events 62 }