initial commit
[govpp.git] / vendor / github.com / onsi / gomega / gexec / build_test.go
1 package gexec_test
2
3 import (
4         "os"
5
6         . "github.com/onsi/ginkgo"
7         . "github.com/onsi/gomega"
8         "github.com/onsi/gomega/gexec"
9 )
10
11 var packagePath = "./_fixture/firefly"
12
13 var _ = Describe(".Build", func() {
14         Context("when there have been previous calls to Build", func() {
15                 BeforeEach(func() {
16                         _, err := gexec.Build(packagePath)
17                         Ω(err).ShouldNot(HaveOccurred())
18                 })
19
20                 It("compiles the specified package", func() {
21                         compiledPath, err := gexec.Build(packagePath)
22                         Ω(err).ShouldNot(HaveOccurred())
23                         Ω(compiledPath).Should(BeAnExistingFile())
24                 })
25
26                 Context("and CleanupBuildArtifacts has been called", func() {
27                         BeforeEach(func() {
28                                 gexec.CleanupBuildArtifacts()
29                         })
30
31                         It("compiles the specified package", func() {
32                                 var err error
33                                 fireflyPath, err = gexec.Build(packagePath)
34                                 Ω(err).ShouldNot(HaveOccurred())
35                                 Ω(fireflyPath).Should(BeAnExistingFile())
36                         })
37                 })
38         })
39 })
40
41 var _ = Describe(".BuildWithEnvironment", func() {
42         var err error
43         env := []string{
44                 "GOOS=linux",
45                 "GOARCH=amd64",
46         }
47
48         It("compiles the specified package with the specified env vars", func() {
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                 _, err = gexec.BuildWithEnvironment(packagePath, env)
56                 Ω(err).ShouldNot(HaveOccurred())
57                 Ω(os.Environ()).ShouldNot(ContainElement("GOOS=linux"))
58         })
59 })