github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/apiserver/agent/model_test.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package agent_test 5 6 import ( 7 jc "github.com/juju/testing/checkers" 8 gc "gopkg.in/check.v1" 9 10 "github.com/juju/juju/apiserver/agent" 11 "github.com/juju/juju/apiserver/common" 12 commontesting "github.com/juju/juju/apiserver/common/testing" 13 apiservertesting "github.com/juju/juju/apiserver/testing" 14 "github.com/juju/juju/juju/testing" 15 "github.com/juju/juju/state" 16 ) 17 18 type modelSuite struct { 19 testing.JujuConnSuite 20 *commontesting.ModelWatcherTest 21 22 authorizer apiservertesting.FakeAuthorizer 23 resources *common.Resources 24 25 machine0 *state.Machine 26 api *agent.AgentAPIV2 27 } 28 29 var _ = gc.Suite(&modelSuite{}) 30 31 func (s *modelSuite) SetUpTest(c *gc.C) { 32 s.JujuConnSuite.SetUpTest(c) 33 34 var err error 35 s.machine0, err = s.State.AddMachine("quantal", state.JobHostUnits, state.JobManageModel) 36 c.Assert(err, jc.ErrorIsNil) 37 38 s.authorizer = apiservertesting.FakeAuthorizer{ 39 Tag: s.machine0.Tag(), 40 } 41 s.resources = common.NewResources() 42 s.AddCleanup(func(_ *gc.C) { s.resources.StopAll() }) 43 44 s.api, err = agent.NewAgentAPIV2( 45 s.State, 46 s.resources, 47 s.authorizer, 48 ) 49 c.Assert(err, jc.ErrorIsNil) 50 s.ModelWatcherTest = commontesting.NewModelWatcherTest( 51 s.api, s.State, s.resources, 52 ) 53 }