Exemple #1
0
func (g *Goop) patchedEnv(replaceGopath bool) env.Env {
	e := env.NewEnv()

	binPath := path.Join(g.vendorDir(), "bin")

	if replaceGopath {
		e["GOPATH"] = g.vendorDir()
	} else {
		e.Prepend("GOPATH", g.vendorDir())
	}
	e["GOBIN"] = binPath
	e.Prepend("PATH", binPath)

	return e
}
Exemple #2
0
)

func Test(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "env")
}

var _ = Describe("env", func() {
	var e env.Env

	BeforeEach(func() {
		os.Setenv("_GOOP_ENV_TEST_FOO", "foo")
		os.Setenv("_GOOP_ENV_TEST_BAR", "bar=bar bar")
		os.Setenv("_GOOP_ENV_TEST_EMPTY", "")

		e = env.NewEnv()
	})

	AfterEach(func() {
		os.Setenv("_GOOP_ENV_TEST_FOO", "")
		os.Setenv("_GOOP_ENV_TEST_BAR", "")
		os.Setenv("_GOOP_ENV_TEST_EMPTY", "")
	})

	Describe("NewEnv()", func() {
		It("returns a new env map using current env vars", func() {
			Expect(e["_GOOP_ENV_TEST_FOO"]).To(Equal("foo"))
			Expect(e["_GOOP_ENV_TEST_BAR"]).To(Equal("bar=bar bar"))
			Expect(e["_GOOP_ENV_TEST_EMPTY"]).To(BeEmpty())
		})
	})