github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/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  	"github.com/juju/cmd"
    11  	jc "github.com/juju/testing/checkers"
    12  	gc "gopkg.in/check.v1"
    13  
    14  	"github.com/juju/juju/cmd/juju/storage"
    15  	"github.com/juju/juju/environs/configstore"
    16  	"github.com/juju/juju/juju/osenv"
    17  	jujutesting "github.com/juju/juju/testing"
    18  )
    19  
    20  func TestAll(t *testing.T) {
    21  	gc.TestingT(t)
    22  }
    23  
    24  type BaseStorageSuite struct {
    25  	jujutesting.FakeJujuHomeSuite
    26  
    27  	command cmd.Command
    28  }
    29  
    30  func (s *BaseStorageSuite) SetUpTest(c *gc.C) {
    31  	s.FakeJujuHomeSuite.SetUpTest(c)
    32  
    33  	s.command = storage.NewSuperCommand()
    34  }
    35  
    36  func (s *BaseStorageSuite) TearDownTest(c *gc.C) {
    37  	s.FakeJujuHomeSuite.TearDownTest(c)
    38  }
    39  
    40  type SubStorageSuite struct {
    41  	jujutesting.BaseSuite
    42  }
    43  
    44  func (s *SubStorageSuite) SetUpTest(c *gc.C) {
    45  	s.BaseSuite.SetUpTest(c)
    46  
    47  	memstore := configstore.NewMem()
    48  	s.PatchValue(&configstore.Default, func() (configstore.Storage, error) {
    49  		return memstore, nil
    50  	})
    51  	os.Setenv(osenv.JujuEnvEnvKey, "testing")
    52  	info := memstore.CreateInfo("testing")
    53  	info.SetBootstrapConfig(map[string]interface{}{"random": "extra data"})
    54  	info.SetAPIEndpoint(configstore.APIEndpoint{
    55  		Addresses:   []string{"127.0.0.1:12345"},
    56  		Hostnames:   []string{"localhost:12345"},
    57  		CACert:      jujutesting.CACert,
    58  		EnvironUUID: "env-uuid",
    59  	})
    60  	info.SetAPICredentials(configstore.APICredentials{
    61  		User:     "user-test",
    62  		Password: "password",
    63  	})
    64  	err := info.Write()
    65  	c.Assert(err, jc.ErrorIsNil)
    66  }