github.com/cloudfoundry-community/cloudfoundry-cli@v6.44.1-0.20240130060226-cda5ed8e89a5+incompatible/util/manifestparser/application_test.go (about)

     1  package manifestparser_test
     2  
     3  import (
     4  	. "code.cloudfoundry.org/cli/util/manifestparser"
     5  	"gopkg.in/yaml.v2"
     6  
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  )
    10  
    11  var _ = Describe("Application", func() {
    12  	Describe("Unmarshal", func() {
    13  		var (
    14  			rawYAML     []byte
    15  			application Application
    16  			executeErr  error
    17  		)
    18  
    19  		JustBeforeEach(func() {
    20  			executeErr = yaml.Unmarshal(rawYAML, &application)
    21  		})
    22  
    23  		Context("when a name is provided", func() {
    24  			BeforeEach(func() {
    25  				rawYAML = []byte(`---
    26  name: spark
    27  `)
    28  			})
    29  
    30  			It("unmarshals the name", func() {
    31  				Expect(executeErr).ToNot(HaveOccurred())
    32  				Expect(application.Name).To(Equal("spark"))
    33  			})
    34  		})
    35  
    36  		Context("when a path is provided", func() {
    37  			BeforeEach(func() {
    38  				rawYAML = []byte(`---
    39  path: /my/path
    40  `)
    41  			})
    42  
    43  			It("unmarshals the name", func() {
    44  				Expect(executeErr).ToNot(HaveOccurred())
    45  				Expect(application.Path).To(Equal("/my/path"))
    46  			})
    47  		})
    48  
    49  		Context("when a docker map is provided", func() {
    50  			BeforeEach(func() {
    51  				rawYAML = []byte(`---
    52  docker:
    53    image: some-image
    54    username: some-username
    55  `)
    56  			})
    57  
    58  			It("unmarshals the name", func() {
    59  				Expect(executeErr).ToNot(HaveOccurred())
    60  				Expect(application.Docker.Image).To(Equal("some-image"))
    61  				Expect(application.Docker.Username).To(Equal("some-username"))
    62  			})
    63  		})
    64  
    65  		Context("when no-route is provided", func() {
    66  			BeforeEach(func() {
    67  				rawYAML = []byte(`---
    68  no-route: true
    69  `)
    70  			})
    71  
    72  			It("unmarshals the name", func() {
    73  				Expect(executeErr).ToNot(HaveOccurred())
    74  				Expect(application.NoRoute).To(BeTrue())
    75  			})
    76  		})
    77  	})
    78  })