Esempio n. 1
0
				fake_command_runner.CommandSpec{
					Path: exec.Command("git").Path,
					Args: []string{"checkout", "some-ref"},
					Dir:  repoPath,
				},
			))
		})

		Context("when git checkout fails", func() {
			disaster := errors.New("oh no!")

			BeforeEach(func() {
				runner.WhenRunning(
					fake_command_runner.CommandSpec{
						Path: exec.Command("git").Path,
						Args: []string{"checkout", "some-ref"},
					}, func(*exec.Cmd) error {
						return disaster
					},
				)
			})

			It("returns the error", func() {
				err := gitRepo.Checkout("some-ref")
				Expect(err).To(HaveOccurred())

				Expect(err).To(Equal(disaster))
			})
		})
	})

	Describe("CurrentVersion", func() {
Esempio n. 2
0
			Path:    "github.com/vito/gocart",
			Version: "v1.2",
		}

		runner = fake_command_runner.New()

		fetcher, err = New(runner)
		Expect(err).ToNot(HaveOccurred())
	})

	Describe("Fetch", func() {
		It("go gets, updates, checkouts, and returns the fetched dependency", func() {
			runner.WhenRunning(fake_command_runner.CommandSpec{
				Path: exec.Command("git").Path,
				Args: []string{"rev-parse", "HEAD"},
			}, func(cmd *exec.Cmd) error {
				cmd.Stdout.Write([]byte("some-sha\n"))
				return nil
			})

			dep, err := fetcher.Fetch(dependency)
			Expect(err).ToNot(HaveOccurred())

			gopath, _ := gopath.InstallationDirectory(os.Getenv("GOPATH"))

			Ω(runner).Should(HaveExecutedSerially(
				fake_command_runner.CommandSpec{
					Path: exec.Command("go").Path,
					Args: []string{"get", "-d", "-v", dependency.Path},
				},
				fake_command_runner.CommandSpec{
Esempio n. 3
0
				fake_command_runner.CommandSpec{
					Path: exec.Command("hg").Path,
					Args: []string{"update", "-c", "some-ref"},
					Dir:  repoPath,
				},
			))
		})

		Context("when hg checkout fails", func() {
			disaster := errors.New("oh no!")

			BeforeEach(func() {
				runner.WhenRunning(
					fake_command_runner.CommandSpec{
						Path: exec.Command("hg").Path,
						Args: []string{"update", "-c", "some-ref"},
					}, func(*exec.Cmd) error {
						return disaster
					},
				)
			})

			It("returns the error", func() {
				err := hgRepo.Checkout("some-ref")
				Expect(err).To(HaveOccurred())

				Expect(err).To(Equal(disaster))
			})
		})
	})

	Describe("CurrentVersion", func() {
Esempio n. 4
0
				fake_command_runner.CommandSpec{
					Path: exec.Command("bzr").Path,
					Args: []string{"update", "-r", "some-ref"},
					Dir:  repoPath,
				},
			))
		})

		Context("when bzr update -r fails", func() {
			disaster := errors.New("oh no!")

			BeforeEach(func() {
				runner.WhenRunning(
					fake_command_runner.CommandSpec{
						Path: exec.Command("bzr").Path,
						Args: []string{"update", "-r", "some-ref"},
					}, func(*exec.Cmd) error {
						return disaster
					},
				)
			})

			It("returns the error", func() {
				err := bzrRepo.Checkout("some-ref")
				Expect(err).To(HaveOccurred())

				Expect(err).To(Equal(disaster))
			})
		})
	})

	Describe("CurrentVersion", func() {