"os"
	"path/filepath"
	"time"

	. "github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/onsi/ginkgo"
	. "github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/onsi/gomega"
	"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/onsi/gomega/gbytes"
	"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/onsi/gomega/gexec"
)

var _ = Describe("Watch", func() {
	var rootPath string
	var pathA string
	var pathB string
	var pathC string
	var session *gexec.Session

	BeforeEach(func() {
		rootPath = tmpPath("root")
		pathA = filepath.Join(rootPath, "src", "github.com", "onsi", "A")
		pathB = filepath.Join(rootPath, "src", "github.com", "onsi", "B")
		pathC = filepath.Join(rootPath, "src", "github.com", "onsi", "C")

		err := os.MkdirAll(pathA, 0700)
		Ω(err).ShouldNot(HaveOccurred())

		err = os.MkdirAll(pathB, 0700)
		Ω(err).ShouldNot(HaveOccurred())

		err = os.MkdirAll(pathC, 0700)
		Ω(err).ShouldNot(HaveOccurred())
Example #2
0
		}

		builderCmd = exec.Command(builderPath, args...)

		builderCmd.Env = os.Environ()
	})

	buildDockerImageURL := func() string {
		parts, err := url.Parse(fakeDockerRegistry.URL())
		Expect(err).NotTo(HaveOccurred())
		return fmt.Sprintf("docker://%s/some-repo", parts.Host)
	}

	Context("when running the main", func() {
		Context("when signalled", func() {
			var session *gexec.Session

			BeforeEach(func() {
				dockerImageURL = buildDockerImageURL()

				parts, err := url.Parse(fakeDockerRegistry.URL())
				Expect(err).NotTo(HaveOccurred())
				dockerRegistryAddresses = parts.Host

				setupFakeDockerRegistry()
				fakeDockerRegistry.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("GET", "/v1/images/id-1/json"),
						http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
							w.Header().Add("X-Docker-Size", "789")
							w.Write([]byte(`{"id":"layer-1","parent":"parent-1","Config":{"Cmd":["-bazbot","-foobar"],"Entrypoint":["/dockerapp","-t"],"WorkingDir":"/workdir"}}`))