github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/cmd/juju/commands/helptool_test.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package commands 5 6 import ( 7 "runtime" 8 "strings" 9 10 gc "gopkg.in/check.v1" 11 12 "github.com/juju/juju/testing" 13 "github.com/juju/juju/worker/uniter/runner/jujuc" 14 ) 15 16 type HelpToolSuite struct { 17 testing.FakeJujuHomeSuite 18 } 19 20 var _ = gc.Suite(&HelpToolSuite{}) 21 22 func (suite *HelpToolSuite) TestHelpToolHelp(c *gc.C) { 23 output := badrun(c, 0, "help", "help-tool") 24 c.Assert(output, gc.Equals, `usage: juju help-tool [tool] 25 purpose: show help on a juju charm tool 26 `) 27 } 28 29 func (suite *HelpToolSuite) TestHelpTool(c *gc.C) { 30 expectedNames := jujuc.CommandNames() 31 output := badrun(c, 0, "help-tool") 32 lines := strings.Split(strings.TrimSpace(output), "\n") 33 for i, line := range lines { 34 lines[i] = strings.Fields(line)[0] 35 } 36 if runtime.GOOS == "windows" { 37 for i, command := range lines { 38 lines[i] = command + ".exe" 39 } 40 } 41 c.Assert(lines, gc.DeepEquals, expectedNames) 42 } 43 44 func (suite *HelpToolSuite) TestHelpToolName(c *gc.C) { 45 var output string 46 if runtime.GOOS == "windows" { 47 output = badrun(c, 0, "help-tool", "relation-get.exe") 48 } else { 49 output = badrun(c, 0, "help-tool", "relation-get") 50 } 51 expectedHelp := `usage: relation-get \[options\] <key> <unit id> 52 purpose: get relation settings 53 54 options: 55 (.|\n)* 56 relation-get prints the value(.|\n)*` 57 c.Assert(output, gc.Matches, expectedHelp) 58 }