Skip to content

Commit

Permalink
fix panics in acceptance tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kira Boyle <kboyle@vmware.com>
  • Loading branch information
jtarchie authored and Kira Boyle committed Nov 2, 2020
1 parent 1104c0f commit b57e3e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions acceptance/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ var _ = Describe("help", func() {
Expect(session.Out.Contents()).Should(ContainSubstring(`om [OPTIONS] <command>`))
})
})

When("given the help command", func() {
It("prints the global usage", func() {
command := exec.Command(pathToMain, "help")
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred())

Eventually(session).Should(gexec.Exit(0))
Expect(session.Out.Contents()).Should(ContainSubstring(`om [OPTIONS] <command>`))
})
})
})
4 changes: 4 additions & 0 deletions cmd/loadConfigFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
// To load vars, VarsFile and/or VarsEnv must exist in the command struct being passed in.
// If VarsEnv is used, envFunc must be defined instead of nil
func loadConfigFile(args []string, envFunc func() []string) ([]string, error) {
if len(args) == 0 {
return args, nil
}

for _, cmdConfigBypassList := range []string{
"interpolate",
"configure-opsman",
Expand Down
8 changes: 8 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func Main(sout io.Writer, serr io.Writer, version string, applySleepDurationStri

args, _ = parser.ParseArgs(args[1:])

if global.Version {
return commands.NewVersion(version, sout).Execute(nil)
}

if len(args) > 0 && args[0] == "help" {
args[0] = "--help"
}

err := setEnvFileProperties(&global)
if err != nil {
return err
Expand Down

0 comments on commit b57e3e8

Please sign in to comment.