github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/integration/push/trigger_legacy_push_test.go (about)

     1  package push
     2  
     3  import (
     4  	"path/filepath"
     5  
     6  	"code.cloudfoundry.org/cli/integration/helpers"
     7  
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gbytes"
    11  	. "github.com/onsi/gomega/gexec"
    12  )
    13  
    14  var _ = Describe("triggering legacy push", func() {
    15  	var (
    16  		appName       string
    17  		host          string
    18  		defaultDomain string
    19  		privateDomain string
    20  	)
    21  
    22  	BeforeEach(func() {
    23  		appName = helpers.NewAppName()
    24  		host = helpers.NewAppName()
    25  		defaultDomain = defaultSharedDomain()
    26  
    27  		privateDomain = helpers.DomainName()
    28  		domain := helpers.NewDomain(organization, privateDomain)
    29  		domain.Create()
    30  	})
    31  
    32  	Context("when there are global properties in the manifest", func() {
    33  		It("triggering old push with deprecation warning", func() {
    34  			helpers.WithHelloWorldApp(func(dir string) {
    35  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
    36  					"host": host,
    37  					"applications": []map[string]string{
    38  						{
    39  							"name": appName,
    40  						},
    41  					},
    42  				})
    43  
    44  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
    45  				Eventually(session.Err).Should(Say("Deprecation warning: Specifying app manifest attributes at the top level is deprecated."))
    46  				Eventually(session.Err).Should(Say("Found: host\\."))
    47  				Eventually(session).Should(Say("Creating route %s\\.%s", host, defaultDomain))
    48  			})
    49  		})
    50  	})
    51  
    52  	Context("when there is an 'inherit' property in the manifest", func() {
    53  		It("triggering old push with deprecation warning", func() {
    54  			helpers.WithHelloWorldApp(func(dir string) {
    55  				helpers.WriteManifest(filepath.Join(dir, "parent.yml"), map[string]interface{}{
    56  					"host": host,
    57  				})
    58  
    59  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
    60  					"inherit": "./parent.yml",
    61  					"applications": []map[string]string{
    62  						{
    63  							"name": appName,
    64  						},
    65  					},
    66  				})
    67  
    68  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
    69  				Eventually(session.Err).Should(Say("Deprecation warning: App manifest inheritance is deprecated."))
    70  				Eventually(session).Should(Say("Creating route %s\\.%s", host, defaultDomain))
    71  				Eventually(session).Should(Say("OK"))
    72  				Eventually(session).Should(Exit(0))
    73  			})
    74  		})
    75  	})
    76  
    77  	Context("when there is a 'domain' property in the manifest", func() {
    78  		It("triggering old push with deprecation warning", func() {
    79  			helpers.WithHelloWorldApp(func(dir string) {
    80  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
    81  					"applications": []map[string]string{
    82  						{
    83  							"name":   appName,
    84  							"domain": defaultDomain,
    85  						},
    86  					},
    87  				})
    88  
    89  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
    90  				Eventually(session.Err).Should(Say("Deprecation warning: Route component attributes 'domain', 'domains', 'host', 'hosts' and 'no-hostname' are deprecated. Found: domain."))
    91  				Eventually(session).Should(Say("(?i)Creating route %s\\.%s", appName, defaultDomain))
    92  				Eventually(session).Should(Say("OK"))
    93  				Eventually(session).Should(Exit(0))
    94  			})
    95  		})
    96  	})
    97  
    98  	Context("when there is a 'domains' property in the manifest", func() {
    99  		It("triggering old push with deprecation warning", func() {
   100  			helpers.WithHelloWorldApp(func(dir string) {
   101  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
   102  					"applications": []map[string]interface{}{
   103  						{
   104  							"name":    appName,
   105  							"domains": []string{defaultDomain},
   106  						},
   107  					},
   108  				})
   109  
   110  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
   111  				Eventually(session.Err).Should(Say("Deprecation warning: Route component attributes 'domain', 'domains', 'host', 'hosts' and 'no-hostname' are deprecated. Found: domains."))
   112  				Eventually(session).Should(Say("(?i)Creating route %s\\.%s", appName, defaultDomain))
   113  				Eventually(session).Should(Say("OK"))
   114  				Eventually(session).Should(Exit(0))
   115  			})
   116  		})
   117  	})
   118  
   119  	Context("when there is a 'host' property in the manifest", func() {
   120  		It("triggering old push with deprecation warning", func() {
   121  			helpers.WithHelloWorldApp(func(dir string) {
   122  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
   123  					"applications": []map[string]string{
   124  						{
   125  							"name": appName,
   126  							"host": host,
   127  						},
   128  					},
   129  				})
   130  
   131  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
   132  				Eventually(session.Err).Should(Say("Deprecation warning: Route component attributes 'domain', 'domains', 'host', 'hosts' and 'no-hostname' are deprecated. Found: host."))
   133  				Eventually(session).Should(Say("(?i)Creating route %s\\.%s", host, defaultDomain))
   134  				Eventually(session).Should(Say("OK"))
   135  				Eventually(session).Should(Exit(0))
   136  			})
   137  		})
   138  	})
   139  
   140  	Context("when there is a 'hosts' property in the manifest", func() {
   141  		It("triggering old push with deprecation warning", func() {
   142  			helpers.WithHelloWorldApp(func(dir string) {
   143  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
   144  					"applications": []map[string]interface{}{
   145  						{
   146  							"name":  appName,
   147  							"hosts": []string{host},
   148  						},
   149  					},
   150  				})
   151  
   152  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
   153  				Eventually(session.Err).Should(Say("Deprecation warning: Route component attributes 'domain', 'domains', 'host', 'hosts' and 'no-hostname' are deprecated. Found: hosts."))
   154  				Eventually(session).Should(Say("(?i)Creating route %s\\.%s", host, defaultDomain))
   155  				Eventually(session).Should(Say("OK"))
   156  				Eventually(session).Should(Exit(0))
   157  			})
   158  		})
   159  	})
   160  
   161  	Context("when there is a 'no-hostname' property in the manifest", func() {
   162  
   163  		It("triggering old push with deprecation warning", func() {
   164  			helpers.WithHelloWorldApp(func(dir string) {
   165  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
   166  					"applications": []map[string]interface{}{
   167  						{
   168  							"name":        appName,
   169  							"no-hostname": true,
   170  						},
   171  					},
   172  				})
   173  
   174  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start", "-d", privateDomain)
   175  				Eventually(session.Err).Should(Say("Deprecation warning: Route component attributes 'domain', 'domains', 'host', 'hosts' and 'no-hostname' are deprecated. Found: no-hostname."))
   176  				Eventually(session).Should(Say("(?i)Creating route %s", privateDomain))
   177  				Eventually(session).Should(Say("OK"))
   178  				Eventually(session).Should(Exit(0))
   179  			})
   180  		})
   181  	})
   182  
   183  	Context("when there is an 'inherit' property and a 'hostname' property in the manifest", func() {
   184  		It("triggering old push with deprecation warning", func() {
   185  			helpers.WithHelloWorldApp(func(dir string) {
   186  				helpers.WriteManifest(filepath.Join(dir, "parent.yml"), map[string]interface{}{
   187  					"domain": privateDomain,
   188  				})
   189  
   190  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
   191  					"inherit": "./parent.yml",
   192  					"applications": []map[string]string{
   193  						{
   194  							"name": appName,
   195  							"host": host,
   196  						},
   197  					},
   198  				})
   199  
   200  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
   201  				Eventually(session.Err).Should(Say("Deprecation warning: App manifest inheritance is deprecated."))
   202  				Eventually(session).Should(Say("Creating route %s\\.%s", host, privateDomain))
   203  				Eventually(session).Should(Say("OK"))
   204  				Eventually(session).Should(Exit(0))
   205  			})
   206  		})
   207  	})
   208  
   209  	Context("when there is a 'domain' property and a 'host' property in the manifest", func() {
   210  		It("triggering old push with deprecation warning", func() {
   211  			helpers.WithHelloWorldApp(func(dir string) {
   212  				helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
   213  					"applications": []map[string]string{
   214  						{
   215  							"name":   appName,
   216  							"domain": privateDomain,
   217  							"host":   host,
   218  						},
   219  					},
   220  				})
   221  
   222  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
   223  				Eventually(session.Err).Should(Say("Deprecation warning: Route component attributes 'domain', 'domains', 'host', 'hosts' and 'no-hostname' are deprecated. Found: domain, host."))
   224  				Eventually(session).Should(Say("(?i)Creating route %s\\.%s", host, privateDomain))
   225  				Eventually(session).Should(Say("OK"))
   226  				Eventually(session).Should(Exit(0))
   227  			})
   228  		})
   229  	})
   230  })