Skip to content

Commit

Permalink
update test for non-codegangsta command requirement execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Leung committed Jun 1, 2015
1 parent 8450cd5 commit 8dc345b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions main/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"time"

. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -51,15 +50,12 @@ var _ = Describe("main", func() {
})

It("runs requirement of the non-codegangsta command", func() {
result := Cf("api")
result2 := Cf("app", "app-should-never-exist-blah-blah")
dir, err := os.Getwd()
Expect(err).ToNot(HaveOccurred())
fullDir := filepath.Join(dir, "..", "fixtures") //set home to a config w/o targeted api
result := CfWith_CF_HOME(fullDir, "app", "app-should-never-exist-blah-blah")

if strings.Contains(string(result.Out.Contents()), "No api endpoint set") {
Eventually(result2.Out).Should(Say("No API endpoint set."))
} else {
Eventually(result2.Out).Should(Say("App app-should-never-exist-blah-blah not found"))
Consistently(result2.Out).ShouldNot(Say("Server error"))
}
Eventually(result.Out).Should(Say("No API endpoint set."))
})
})

Expand Down Expand Up @@ -277,6 +273,17 @@ func CfWithIo(command string, args string) *Session {

return session
}
func CfWith_CF_HOME(cfHome string, args ...string) *Session {
path, err := Build("github.com/cloudfoundry/cli/main")
Expect(err).NotTo(HaveOccurred())

cmd := exec.Command(path, args...)
cmd.Env = append(cmd.Env, "CF_HOME="+cfHome)
session, err := Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())

return session
}

// gexec.Build leaves a compiled binary behind in /tmp.
var _ = AfterSuite(func() {
Expand Down

0 comments on commit 8dc345b

Please sign in to comment.