github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/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.FakeJujuXDGDataHomeSuite
    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  
    26  Summary:
    27  Show help on a Juju charm tool.
    28  `)
    29  }
    30  
    31  func (suite *HelpToolSuite) TestHelpTool(c *gc.C) {
    32  	expectedNames := jujuc.CommandNames()
    33  	output := badrun(c, 0, "help-tool")
    34  	lines := strings.Split(strings.TrimSpace(output), "\n")
    35  	for i, line := range lines {
    36  		lines[i] = strings.Fields(line)[0]
    37  	}
    38  	if runtime.GOOS == "windows" {
    39  		for i, command := range lines {
    40  			lines[i] = command + ".exe"
    41  		}
    42  	}
    43  	c.Assert(lines, gc.DeepEquals, expectedNames)
    44  }
    45  
    46  func (suite *HelpToolSuite) TestHelpToolName(c *gc.C) {
    47  	var output string
    48  	if runtime.GOOS == "windows" {
    49  		output = badrun(c, 0, "help-tool", "relation-get.exe")
    50  	} else {
    51  		output = badrun(c, 0, "help-tool", "relation-get")
    52  	}
    53  	expectedHelp := `Usage: relation-get \[options\] <key> <unit id>
    54  
    55  Summary:
    56  get relation settings
    57  
    58  Options:
    59  (.|\n)*
    60  
    61  Details:
    62  relation-get prints the value(.|\n)*`
    63  	c.Assert(output, gc.Matches, expectedHelp)
    64  }