github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/cmd/juju/controller/package_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package controller_test 5 6 import ( 7 "testing" 8 9 jc "github.com/juju/testing/checkers" 10 gc "gopkg.in/check.v1" 11 12 "github.com/juju/juju/jujuclient" 13 "github.com/juju/juju/jujuclient/jujuclienttesting" 14 coretesting "github.com/juju/juju/testing" 15 ) 16 17 func TestPackage(t *testing.T) { 18 gc.TestingT(t) 19 } 20 21 type baseControllerSuite struct { 22 coretesting.FakeJujuXDGDataHomeSuite 23 store jujuclient.ClientStore 24 controllersYaml, modelsYaml, accountsYaml string 25 expectedOutput, expectedErr string 26 } 27 28 func (s *baseControllerSuite) SetUpTest(c *gc.C) { 29 s.FakeJujuXDGDataHomeSuite.SetUpTest(c) 30 s.controllersYaml = testControllersYaml 31 s.modelsYaml = testModelsYaml 32 s.accountsYaml = testAccountsYaml 33 s.store = jujuclienttesting.MinimalStore() 34 } 35 36 func (s *baseControllerSuite) createTestClientStore(c *gc.C) *jujuclient.MemStore { 37 controllers, err := jujuclient.ParseControllers([]byte(s.controllersYaml)) 38 c.Assert(err, jc.ErrorIsNil) 39 40 models, err := jujuclient.ParseModels([]byte(s.modelsYaml)) 41 c.Assert(err, jc.ErrorIsNil) 42 43 accounts, err := jujuclient.ParseAccounts([]byte(s.accountsYaml)) 44 c.Assert(err, jc.ErrorIsNil) 45 46 store := jujuclient.NewMemStore() 47 store.Controllers = controllers.Controllers 48 store.CurrentControllerName = controllers.CurrentController 49 store.Models = models 50 store.Accounts = accounts 51 s.store = store 52 return store 53 } 54 55 const testControllersYaml = ` 56 controllers: 57 aws-test: 58 uuid: this-is-the-aws-test-uuid 59 api-endpoints: [this-is-aws-test-of-many-api-endpoints] 60 ca-cert: this-is-aws-test-ca-cert 61 cloud: aws 62 region: us-east-1 63 model-count: 2 64 machine-count: 5 65 agent-version: 2.0.1 66 mallards: 67 uuid: this-is-another-uuid 68 api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints] 69 ca-cert: this-is-another-ca-cert 70 cloud: mallards 71 region: mallards1 72 mark-test-prodstack: 73 uuid: this-is-a-uuid 74 api-endpoints: [this-is-one-of-many-api-endpoints] 75 ca-cert: this-is-a-ca-cert 76 cloud: prodstack 77 current-controller: mallards 78 ` 79 80 const testModelsYaml = ` 81 controllers: 82 aws-test: 83 models: 84 controller: 85 uuid: ghi 86 type: iaas 87 current-model: admin/controller 88 mallards: 89 models: 90 model0: 91 uuid: abc 92 type: iaas 93 my-model: 94 uuid: def 95 type: iaas 96 current-model: admin/my-model 97 ` 98 99 const testAccountsYaml = ` 100 controllers: 101 aws-test: 102 user: admin 103 password: hun+er2 104 mark-test-prodstack: 105 user: admin 106 password: hunter2 107 mallards: 108 user: admin 109 password: hunter2 110 last-known-access: superuser 111 `