github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/actor/v7pushaction/handle_task_override_test.go (about)

     1  package v7pushaction_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/command/translatableerror"
     5  	"code.cloudfoundry.org/cli/util/manifestparser"
     6  
     7  	. "code.cloudfoundry.org/cli/actor/v7pushaction"
     8  
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  var _ = Describe("HandleTaskOverride", func() {
    14  	var (
    15  		originalManifest    manifestparser.Manifest
    16  		transformedManifest manifestparser.Manifest
    17  		overrides           FlagOverrides
    18  		executeErr          error
    19  	)
    20  
    21  	BeforeEach(func() {
    22  		originalManifest = manifestparser.Manifest{
    23  			Applications: []manifestparser.Application{{}},
    24  		}
    25  		overrides = FlagOverrides{}
    26  	})
    27  
    28  	JustBeforeEach(func() {
    29  		transformedManifest, executeErr = HandleTaskOverride(originalManifest, overrides)
    30  	})
    31  
    32  	When("task is set on the flag overrides", func() {
    33  		BeforeEach(func() {
    34  			overrides.Task = true
    35  		})
    36  
    37  		It("changes the no-route of the only app in the manifest", func() {
    38  			Expect(executeErr).ToNot(HaveOccurred())
    39  			Expect(transformedManifest.Applications).To(ConsistOf(
    40  				manifestparser.Application{
    41  					NoRoute: true,
    42  				},
    43  			))
    44  		})
    45  	})
    46  
    47  	When("task flag is set and there are multiple apps in the manifest", func() {
    48  		BeforeEach(func() {
    49  			overrides.Task = true
    50  
    51  			originalManifest.Applications = []manifestparser.Application{
    52  				{},
    53  				{},
    54  			}
    55  		})
    56  
    57  		It("returns an error", func() {
    58  			Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{}))
    59  		})
    60  	})
    61  })