github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/cmd/juju/storage/package_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package storage_test
     5  
     6  import (
     7  	"os"
     8  	"testing"
     9  
    10  	jc "github.com/juju/testing/checkers"
    11  	gc "gopkg.in/check.v1"
    12  
    13  	"github.com/juju/juju/cmd/juju/storage"
    14  	"github.com/juju/juju/environs/configstore"
    15  	"github.com/juju/juju/juju/osenv"
    16  	jujutesting "github.com/juju/juju/testing"
    17  )
    18  
    19  func TestAll(t *testing.T) {
    20  	gc.TestingT(t)
    21  }
    22  
    23  type BaseStorageSuite struct {
    24  	jujutesting.FakeJujuHomeSuite
    25  
    26  	command *storage.Command
    27  }
    28  
    29  func (s *BaseStorageSuite) SetUpTest(c *gc.C) {
    30  	s.FakeJujuHomeSuite.SetUpTest(c)
    31  
    32  	s.command = storage.NewSuperCommand().(*storage.Command)
    33  }
    34  
    35  func (s *BaseStorageSuite) TearDownTest(c *gc.C) {
    36  	s.FakeJujuHomeSuite.TearDownTest(c)
    37  }
    38  
    39  type SubStorageSuite struct {
    40  	jujutesting.BaseSuite
    41  }
    42  
    43  func (s *SubStorageSuite) SetUpTest(c *gc.C) {
    44  	s.BaseSuite.SetUpTest(c)
    45  
    46  	memstore := configstore.NewMem()
    47  	s.PatchValue(&configstore.Default, func() (configstore.Storage, error) {
    48  		return memstore, nil
    49  	})
    50  	os.Setenv(osenv.JujuEnvEnvKey, "testing")
    51  	info := memstore.CreateInfo("testing")
    52  	info.SetBootstrapConfig(map[string]interface{}{"random": "extra data"})
    53  	info.SetAPIEndpoint(configstore.APIEndpoint{
    54  		Addresses:   []string{"127.0.0.1:12345"},
    55  		Hostnames:   []string{"localhost:12345"},
    56  		CACert:      jujutesting.CACert,
    57  		EnvironUUID: "env-uuid",
    58  	})
    59  	info.SetAPICredentials(configstore.APICredentials{
    60  		User:     "user-test",
    61  		Password: "password",
    62  	})
    63  	err := info.Write()
    64  	c.Assert(err, jc.ErrorIsNil)
    65  }