github.com/cloudfoundry-community/cloudfoundry-cli@v6.44.1-0.20240130060226-cda5ed8e89a5+incompatible/actor/v7pushaction/v7pushaction_suite_test.go (about)

     1  package v7pushaction_test
     2  
     3  import (
     4  	"os"
     5  	"time"
     6  
     7  	. "code.cloudfoundry.org/cli/actor/v7pushaction"
     8  	"code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes"
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  	"testing"
    12  
    13  	log "github.com/sirupsen/logrus"
    14  )
    15  
    16  func TestPushAction(t *testing.T) {
    17  	RegisterFailHandler(Fail)
    18  	RunSpecs(t, "V7 Push Actions Suite")
    19  }
    20  
    21  var _ = BeforeEach(func() {
    22  	SetDefaultEventuallyTimeout(3 * time.Second)
    23  	log.SetLevel(log.PanicLevel)
    24  })
    25  
    26  func getCurrentDir() string {
    27  	pwd, err := os.Getwd()
    28  	Expect(err).NotTo(HaveOccurred())
    29  	return pwd
    30  }
    31  
    32  func getTestPushActor() (*Actor, *v7pushactionfakes.FakeV2Actor, *v7pushactionfakes.FakeV7Actor, *v7pushactionfakes.FakeSharedActor) {
    33  	fakeV2Actor := new(v7pushactionfakes.FakeV2Actor)
    34  	fakeV7Actor := new(v7pushactionfakes.FakeV7Actor)
    35  	fakeSharedActor := new(v7pushactionfakes.FakeSharedActor)
    36  	actor := NewActor(fakeV2Actor, fakeV7Actor, fakeSharedActor)
    37  	return actor, fakeV2Actor, fakeV7Actor, fakeSharedActor
    38  }
    39  
    40  func EventFollower(wrapper func(eventStream chan<- Event)) []Event {
    41  	eventStream := make(chan Event)
    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)
    54  		}
    55  	}()
    56  
    57  	wrapper(eventStream)
    58  	close(eventStream)
    59  
    60  	<-closed
    61  	return events
    62  }