github.com/arunkumar7540/cli@v6.45.0+incompatible/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.FakeV2Actor, *v7pushactionfakes.FakeV7Actor, *v7pushactionfakes.FakeSharedActor) {
    34  	fakeV2Actor := new(v7pushactionfakes.FakeV2Actor)
    35  	fakeV7Actor := new(v7pushactionfakes.FakeV7Actor)
    36  	fakeSharedActor := new(v7pushactionfakes.FakeSharedActor)
    37  	actor := NewActor(fakeV2Actor, fakeV7Actor, fakeSharedActor)
    38  	return actor, fakeV2Actor, fakeV7Actor, fakeSharedActor
    39  }
    40  
    41  func EventFollower(wrapper func(eventStream chan<- Event)) []Event {
    42  	eventStream := make(chan Event)
    43  	closed := make(chan bool)
    44  
    45  	var events []Event
    46  
    47  	go func() {
    48  		for {
    49  			event, ok := <-eventStream
    50  			if !ok {
    51  				close(closed)
    52  				return
    53  			}
    54  			events = append(events, event)
    55  		}
    56  	}()
    57  
    58  	wrapper(eventStream)
    59  	close(eventStream)
    60  
    61  	<-closed
    62  	return events
    63  }