github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/integration/isolated/copy_source_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"net/http"
     7  
     8  	"code.cloudfoundry.org/cli/integration/helpers"
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  	. "github.com/onsi/gomega/gbytes"
    12  	. "github.com/onsi/gomega/gexec"
    13  )
    14  
    15  var _ = Describe("copy-source command", func() {
    16  	var appName1, appName2 string
    17  
    18  	BeforeEach(func() {
    19  		setupCF(helpers.NewOrgName(), helpers.PrefixedRandomName("SPACE"))
    20  
    21  		appName1 = helpers.PrefixedRandomName("hello")
    22  		appName2 = helpers.PrefixedRandomName("banana")
    23  
    24  		helpers.WithHelloWorldApp(func(appDir string) {
    25  			Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0))
    26  		})
    27  
    28  		helpers.WithBananaPantsApp(func(appDir string) {
    29  			Eventually(helpers.CF("push", appName2, "--no-start", "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0))
    30  		})
    31  	})
    32  
    33  	It("copies the app", func() {
    34  		session := helpers.CF("copy-source", appName1, appName2)
    35  		Eventually(session).Should(Say("Copying source from app %s to target app %s", appName1, appName2))
    36  		Eventually(session).Should(Say("Showing health and status for app %s", appName2))
    37  		Eventually(session).Should(Exit(0))
    38  
    39  		resp, err := http.Get(fmt.Sprintf("http://%s.%s", appName2, defaultSharedDomain()))
    40  		Expect(err).ToNot(HaveOccurred())
    41  		defer resp.Body.Close()
    42  		body, err := ioutil.ReadAll(resp.Body)
    43  		Expect(err).ToNot(HaveOccurred())
    44  		Expect(string(body)).To(MatchRegexp("hello world"))
    45  	})
    46  })