github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/models/route_summary_test.go (about)

     1  package models_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/cf/models"
     5  
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  )
     9  
    10  var _ = Describe("RouteSummary", func() {
    11  	Describe("URL", func() {
    12  		var (
    13  			r    models.RouteSummary
    14  			host string
    15  			path string
    16  			port int
    17  		)
    18  
    19  		BeforeEach(func() {
    20  			host = ""
    21  			path = ""
    22  			port = 0
    23  		})
    24  
    25  		JustBeforeEach(func() {
    26  			r = models.RouteSummary{
    27  				Host: host,
    28  				Domain: models.DomainFields{
    29  					Name: "the-domain",
    30  				},
    31  				Path: path,
    32  				Port: port,
    33  			}
    34  		})
    35  
    36  		Context("when the host is blank", func() {
    37  			BeforeEach(func() {
    38  				host = ""
    39  			})
    40  
    41  			It("returns the domain", func() {
    42  				Expect(r.URL()).To(Equal("the-domain"))
    43  			})
    44  
    45  			Context("when the path is present", func() {
    46  				BeforeEach(func() {
    47  					path = "/the-path"
    48  				})
    49  
    50  				It("returns the domain and path", func() {
    51  					Expect(r.URL()).To(Equal("the-domain/the-path"))
    52  				})
    53  			})
    54  
    55  			Context("when the port is present", func() {
    56  				BeforeEach(func() {
    57  					port = 9001
    58  				})
    59  
    60  				It("returns the port", func() {
    61  					Expect(r.URL()).To(Equal("the-domain:9001"))
    62  				})
    63  			})
    64  		})
    65  
    66  		Context("when the host is not blank", func() {
    67  			BeforeEach(func() {
    68  				host = "the-host"
    69  			})
    70  
    71  			It("returns the host and domain", func() {
    72  				Expect(r.URL()).To(Equal("the-host.the-domain"))
    73  			})
    74  
    75  			Context("when the path is present", func() {
    76  				BeforeEach(func() {
    77  					path = "/the-path"
    78  				})
    79  
    80  				It("returns the host and domain and path", func() {
    81  					Expect(r.URL()).To(Equal("the-host.the-domain/the-path"))
    82  				})
    83  			})
    84  		})
    85  	})
    86  })