github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/apiserver/storage/storage_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 jc "github.com/juju/testing/checkers" 8 gc "gopkg.in/check.v1" 9 10 "github.com/juju/juju/apiserver/params" 11 "github.com/juju/juju/apiserver/storage" 12 "github.com/juju/juju/apiserver/testing" 13 jujutesting "github.com/juju/juju/juju/testing" 14 ) 15 16 type storageSuite struct { 17 // TODO(anastasiamac) mock to remove JujuConnSuite 18 jujutesting.JujuConnSuite 19 20 api *storage.API 21 authorizer testing.FakeAuthorizer 22 } 23 24 var _ = gc.Suite(&storageSuite{}) 25 26 func (s *storageSuite) SetUpTest(c *gc.C) { 27 s.JujuConnSuite.SetUpTest(c) 28 s.authorizer = testing.FakeAuthorizer{ 29 Tag: s.AdminUserTag(c), 30 } 31 var err error 32 s.api, err = storage.NewAPI(s.State, nil, s.authorizer) 33 c.Assert(err, jc.ErrorIsNil) 34 } 35 36 func (s *storageSuite) TestShowStorage(c *gc.C) { 37 // TODO(anastasiamac) update when s.Factory.MakeStorage or similar is available 38 storageTag := "test-storage" 39 entity := params.Entity{Tag: storageTag} 40 41 found, err := s.api.Show(params.Entities{Entities: []params.Entity{entity}}) 42 c.Assert(err, jc.ErrorIsNil) 43 c.Assert(found.Results, gc.HasLen, 1) 44 c.Assert(found.Results[0].Error.Error.Error(), gc.Matches, ".*permission denied*") 45 }