コード例 #1
0
	)

	BeforeEach(func() {
		port := "8282"
		host = fmt.Sprintf("http://localhost:%s", port)
		err := os.Setenv("PORT", port)
		Expect(err).ShouldNot(HaveOccurred())

		command := exec.Command(pathToBinary)
		session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
		Expect(err).ShouldNot(HaveOccurred())
		time.Sleep(1 * time.Second)
	})

	AfterEach(func() {
		session.Terminate().Wait()
	})

	It("PUTs then GETs the latest stemcell for the given products", func() {

		products := map[string]string{
			"cf-mysql":   "3026",
			"cf-riak-cs": "3030",
		}

		for product, expectedStemcell := range products {
			url := fmt.Sprintf("%s/stemcell?product_name=%s", host, product)
			req, err := http.NewRequest("PUT", url, strings.NewReader(expectedStemcell))
			Expect(err).ToNot(HaveOccurred())

			resp, err := http.DefaultClient.Do(req)