github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/cmd/juju/charms/charms_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package charms_test 5 6 import ( 7 "os" 8 9 jc "github.com/juju/testing/checkers" 10 gc "gopkg.in/check.v1" 11 12 "github.com/juju/juju/cmd/juju/charms" 13 "github.com/juju/juju/environs/configstore" 14 "github.com/juju/juju/juju/osenv" 15 "github.com/juju/juju/testing" 16 ) 17 18 type CharmsCommandSuite struct { 19 testing.BaseSuite 20 } 21 22 var _ = gc.Suite(&CharmsCommandSuite{}) 23 24 var expectedCharmsCommmandNames = []string{ 25 "help", 26 "list", 27 } 28 29 func (s *CharmsCommandSuite) TestHelp(c *gc.C) { 30 // Check the help output 31 ctx, err := testing.RunCommand(c, charms.NewSuperCommand(), "--help") 32 c.Assert(err, jc.ErrorIsNil) 33 namesFound := testing.ExtractCommandsFromHelpOutput(ctx) 34 c.Assert(namesFound, gc.DeepEquals, expectedCharmsCommmandNames) 35 } 36 37 type BaseSuite struct { 38 testing.BaseSuite 39 } 40 41 func (s *BaseSuite) SetUpTest(c *gc.C) { 42 s.BaseSuite.SetUpTest(c) 43 memstore := configstore.NewMem() 44 s.PatchValue(&configstore.Default, func() (configstore.Storage, error) { 45 return memstore, nil 46 }) 47 os.Setenv(osenv.JujuEnvEnvKey, "testing") 48 info := memstore.CreateInfo("testing") 49 info.SetBootstrapConfig(map[string]interface{}{"random": "extra data"}) 50 info.SetAPIEndpoint(configstore.APIEndpoint{ 51 Addresses: []string{"127.0.0.1:12345"}, 52 Hostnames: []string{"localhost:12345"}, 53 CACert: testing.CACert, 54 EnvironUUID: "env-uuid", 55 }) 56 info.SetAPICredentials(configstore.APICredentials{ 57 User: "user-test", 58 Password: "password", 59 }) 60 err := info.Write() 61 c.Assert(err, jc.ErrorIsNil) 62 }