github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/cmd/plugins/local/main_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package local_test
     5  
     6  import (
     7  	"strings"
     8  
     9  	gc "launchpad.net/gocheck"
    10  
    11  	"launchpad.net/juju-core/cmd/plugins/local"
    12  	"launchpad.net/juju-core/testing"
    13  	"launchpad.net/juju-core/testing/testbase"
    14  )
    15  
    16  type mainSuite struct {
    17  	testbase.LoggingSuite
    18  }
    19  
    20  var _ = gc.Suite(&mainSuite{})
    21  
    22  func (*mainSuite) TestRegisteredCommands(c *gc.C) {
    23  	expectedSubcommands := []string{
    24  		"help",
    25  		// TODO: add some as they get registered
    26  	}
    27  	plugin := local.JujuLocalPlugin()
    28  	ctx, err := testing.RunCommand(c, plugin, []string{"help", "commands"})
    29  	c.Assert(err, gc.IsNil)
    30  
    31  	lines := strings.Split(testing.Stdout(ctx), "\n")
    32  	var names []string
    33  	for _, line := range lines {
    34  		f := strings.Fields(line)
    35  		if len(f) == 0 {
    36  			continue
    37  		}
    38  		names = append(names, f[0])
    39  	}
    40  	// The names should be output in alphabetical order, so don't sort.
    41  	c.Assert(names, gc.DeepEquals, expectedSubcommands)
    42  }