github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/state/environ_test.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package state_test 5 6 import ( 7 gc "launchpad.net/gocheck" 8 9 "launchpad.net/juju-core/state" 10 ) 11 12 type EnvironSuite struct { 13 ConnSuite 14 env *state.Environment 15 } 16 17 var _ = gc.Suite(&EnvironSuite{}) 18 19 func (s *EnvironSuite) SetUpTest(c *gc.C) { 20 s.ConnSuite.SetUpTest(c) 21 env, err := s.State.Environment() 22 c.Assert(err, gc.IsNil) 23 s.env = env 24 } 25 26 func (s *EnvironSuite) TestTag(c *gc.C) { 27 expected := "environment-" + s.env.UUID() 28 c.Assert(s.env.Tag(), gc.Equals, expected) 29 } 30 31 func (s *EnvironSuite) TestName(c *gc.C) { 32 c.Assert(s.env.Name(), gc.Equals, "testenv") 33 } 34 35 func (s *EnvironSuite) TestUUID(c *gc.C) { 36 uuidA := s.env.UUID() 37 c.Assert(uuidA, gc.HasLen, 36) 38 39 // Check that two environments have different UUIDs. 40 s.State.Close() 41 s.MgoSuite.TearDownTest(c) 42 s.MgoSuite.SetUpTest(c) 43 s.State = state.TestingInitialize(c, nil, state.Policy(nil)) 44 env, err := s.State.Environment() 45 c.Assert(err, gc.IsNil) 46 uuidB := env.UUID() 47 c.Assert(uuidA, gc.Not(gc.Equals), uuidB) 48 } 49 50 func (s *EnvironSuite) TestAnnotatorForEnvironment(c *gc.C) { 51 testAnnotator(c, func() (state.Annotator, error) { 52 return s.State.Environment() 53 }) 54 }