0 | 0 |
package gexec_test
|
1 | 1 |
|
2 | 2 |
import (
|
|
3 |
"os"
|
|
4 |
|
3 | 5 |
. "github.com/onsi/ginkgo"
|
4 | 6 |
. "github.com/onsi/gomega"
|
5 | 7 |
"github.com/onsi/gomega/gexec"
|
6 | 8 |
)
|
7 | 9 |
|
|
10 |
var packagePath = "./_fixture/firefly"
|
|
11 |
|
8 | 12 |
var _ = Describe(".Build", func() {
|
9 | |
var packagePath = "./_fixture/firefly"
|
10 | |
|
11 | 13 |
Context("when there have been previous calls to Build", func() {
|
12 | 14 |
BeforeEach(func() {
|
13 | 15 |
_, err := gexec.Build(packagePath)
|
|
34 | 36 |
})
|
35 | 37 |
})
|
36 | 38 |
})
|
|
39 |
|
|
40 |
var _ = Describe(".BuildWithEnvironment", func() {
|
|
41 |
var err error
|
|
42 |
|
|
43 |
It("compiles the specified package with the specified env vars", func() {
|
|
44 |
env := map[string]string{
|
|
45 |
"GOOS": "linux",
|
|
46 |
"GOARCH": "amd64",
|
|
47 |
}
|
|
48 |
|
|
49 |
compiledPath, err := gexec.BuildWithEnvironment(packagePath, env)
|
|
50 |
Ω(err).ShouldNot(HaveOccurred())
|
|
51 |
Ω(compiledPath).Should(BeAnExistingFile())
|
|
52 |
})
|
|
53 |
|
|
54 |
It("returns the environment to a good state", func() {
|
|
55 |
knownGoodEnv := os.Environ()
|
|
56 |
|
|
57 |
env := map[string]string{
|
|
58 |
"THIS_ENV_VAR": "SHOULD_NOT_BE_SET",
|
|
59 |
}
|
|
60 |
|
|
61 |
_, err = gexec.BuildWithEnvironment(packagePath, env)
|
|
62 |
Ω(err).ShouldNot(HaveOccurred())
|
|
63 |
|
|
64 |
Ω(os.Environ()).Should(Equal(knownGoodEnv))
|
|
65 |
})
|
|
66 |
})
|