github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/actor/v7pushaction/handle_default_route_override_test.go (about)

     1  package v7pushaction_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/util/manifestparser"
     5  
     6  	. "code.cloudfoundry.org/cli/actor/v7pushaction"
     7  
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  )
    11  
    12  var _ = Describe("HandleDefualtRouteOverride", func() {
    13  	var (
    14  		originalManifest    manifestparser.Manifest
    15  		transformedManifest manifestparser.Manifest
    16  		overrides           FlagOverrides
    17  		executeErr          error
    18  	)
    19  
    20  	BeforeEach(func() {
    21  		originalManifest = manifestparser.Manifest{}
    22  		overrides = FlagOverrides{}
    23  	})
    24  
    25  	JustBeforeEach(func() {
    26  		transformedManifest, executeErr = HandleDefaultRouteOverride(originalManifest, overrides)
    27  	})
    28  
    29  	When("the manifest has the no-route field", func() {
    30  		BeforeEach(func() {
    31  			originalManifest = manifestparser.Manifest{
    32  				Applications: []manifestparser.Application{{NoRoute: true}},
    33  			}
    34  		})
    35  		It("does not add default route", func() {
    36  			Expect(executeErr).NotTo(HaveOccurred())
    37  			Expect(transformedManifest).To(Equal(manifestparser.Manifest{
    38  				Applications: []manifestparser.Application{{NoRoute: true}},
    39  			}))
    40  		})
    41  
    42  	})
    43  
    44  	When("the manifest has the random-route field", func() {
    45  		BeforeEach(func() {
    46  			originalManifest = manifestparser.Manifest{
    47  				Applications: []manifestparser.Application{{RandomRoute: true}},
    48  			}
    49  		})
    50  		It("does not add default route", func() {
    51  			Expect(executeErr).NotTo(HaveOccurred())
    52  			Expect(transformedManifest).To(Equal(manifestparser.Manifest{
    53  				Applications: []manifestparser.Application{{RandomRoute: true}},
    54  			}))
    55  
    56  		})
    57  
    58  	})
    59  
    60  	// CLI doesnt know about the routes field but CAPI ignores defualt route if routes is specified
    61  	// so we are ok adding defualt route even with the presence of a routes field
    62  
    63  	When("the manifest has no routing fields", func() {
    64  		BeforeEach(func() {
    65  			originalManifest = manifestparser.Manifest{
    66  				Applications: []manifestparser.Application{{}},
    67  			}
    68  		})
    69  		It("does add default route", func() {
    70  			Expect(executeErr).NotTo(HaveOccurred())
    71  			Expect(transformedManifest).To(Equal(manifestparser.Manifest{
    72  				Applications: []manifestparser.Application{{DefaultRoute: true}},
    73  			}))
    74  
    75  		})
    76  
    77  	})
    78  
    79  })