github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/worker/uniter/upgrade126_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package uniter_test 5 6 import ( 7 jc "github.com/juju/testing/checkers" 8 gc "gopkg.in/check.v1" 9 "gopkg.in/juju/charm.v6-unstable" 10 "gopkg.in/juju/charm.v6-unstable/hooks" 11 12 "github.com/juju/juju/worker/uniter" 13 "github.com/juju/juju/worker/uniter/hook" 14 "github.com/juju/juju/worker/uniter/operation" 15 ) 16 17 func (s *upgradeStateContextSuite) TestInstalledBooleanFalseIfInstalling(c *gc.C) { 18 oldState := &operation.State{ 19 Kind: operation.Install, 20 Step: operation.Pending, 21 CharmURL: charm.MustParseURL("local:quantal/charm"), 22 } 23 err := s.statefile.Write(oldState) 24 c.Assert(err, jc.ErrorIsNil) 25 err = uniter.AddInstalledToUniterState(s.unitTag, s.datadir) 26 c.Assert(err, jc.ErrorIsNil) 27 newState := s.readState(c) 28 c.Assert(newState.Installed, gc.Equals, false) 29 } 30 31 func (s *upgradeStateContextSuite) TestInstalledBooleanFalseIfRunHookInstalling(c *gc.C) { 32 oldState := &operation.State{ 33 Kind: operation.RunHook, 34 Step: operation.Pending, 35 Hook: &hook.Info{ 36 Kind: hooks.Install, 37 }, 38 } 39 err := s.statefile.Write(oldState) 40 c.Assert(err, jc.ErrorIsNil) 41 err = uniter.AddInstalledToUniterState(s.unitTag, s.datadir) 42 c.Assert(err, jc.ErrorIsNil) 43 newState := s.readState(c) 44 c.Assert(newState.Installed, gc.Equals, false) 45 } 46 47 func (s *upgradeStateContextSuite) TestInstalledBooleanTrueIfInstalled(c *gc.C) { 48 oldState := &operation.State{ 49 Kind: operation.Continue, 50 Step: operation.Pending, 51 } 52 err := s.statefile.Write(oldState) 53 c.Assert(err, jc.ErrorIsNil) 54 err = uniter.AddInstalledToUniterState(s.unitTag, s.datadir) 55 c.Assert(err, jc.ErrorIsNil) 56 newState := s.readState(c) 57 c.Assert(newState.Installed, gc.Equals, true) 58 }