github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/state/testing/suite_wallclock.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package testing 5 6 import ( 7 "github.com/juju/testing" 8 gc "gopkg.in/check.v1" 9 "gopkg.in/juju/names.v2" 10 11 "github.com/juju/juju/cloud" 12 "github.com/juju/juju/environs/config" 13 "github.com/juju/juju/state" 14 coretesting "github.com/juju/juju/testing" 15 "github.com/juju/juju/testing/factory" 16 ) 17 18 var _ = gc.Suite(&StateWithWallClockSuite{}) 19 20 // StateWithWallClockSuite provides setup and teardown for tests that require a 21 // state.State. This should be deprecated in favour of StateSuite, and tests 22 // updated to use the testing clock StateSuite provides. 23 type StateWithWallClockSuite struct { 24 testing.MgoSuite 25 coretesting.BaseSuite 26 NewPolicy state.NewPolicyFunc 27 State *state.State 28 Owner names.UserTag 29 Factory *factory.Factory 30 InitialConfig *config.Config 31 ControllerInheritedConfig map[string]interface{} 32 RegionConfig cloud.RegionConfig 33 } 34 35 func (s *StateWithWallClockSuite) SetUpSuite(c *gc.C) { 36 s.MgoSuite.SetUpSuite(c) 37 s.BaseSuite.SetUpSuite(c) 38 } 39 40 func (s *StateWithWallClockSuite) TearDownSuite(c *gc.C) { 41 s.BaseSuite.TearDownSuite(c) 42 s.MgoSuite.TearDownSuite(c) 43 } 44 45 func (s *StateWithWallClockSuite) SetUpTest(c *gc.C) { 46 s.MgoSuite.SetUpTest(c) 47 s.BaseSuite.SetUpTest(c) 48 49 s.Owner = names.NewLocalUserTag("test-admin") 50 s.State = Initialize(c, s.Owner, s.InitialConfig, s.ControllerInheritedConfig, s.RegionConfig, s.NewPolicy) 51 s.AddCleanup(func(*gc.C) { s.State.Close() }) 52 s.Factory = factory.NewFactory(s.State) 53 } 54 55 func (s *StateWithWallClockSuite) TearDownTest(c *gc.C) { 56 s.BaseSuite.TearDownTest(c) 57 s.MgoSuite.TearDownTest(c) 58 }