github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/apiserver/restoring_root_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package apiserver_test 5 6 import ( 7 _ "github.com/juju/testing/checkers" 8 jc "github.com/juju/testing/checkers" 9 gc "gopkg.in/check.v1" 10 11 "github.com/juju/juju/apiserver" 12 "github.com/juju/juju/testing" 13 ) 14 15 type restoreRootSuite struct { 16 testing.BaseSuite 17 } 18 19 var _ = gc.Suite(&restoreRootSuite{}) 20 21 func (r *restoreRootSuite) TestFindAllowedMethodWhenPreparing(c *gc.C) { 22 root := apiserver.TestingAboutToRestoreRoot(nil) 23 24 caller, err := root.FindMethod("Backups", 1, "Restore") 25 26 c.Assert(err, jc.ErrorIsNil) 27 c.Assert(caller, gc.NotNil) 28 } 29 30 func (r *restoreRootSuite) TestNothingAllowedMethodWhenPreparing(c *gc.C) { 31 root := apiserver.TestingRestoreInProgressRoot(nil) 32 33 caller, err := root.FindMethod("Service", 3, "Deploy") 34 35 c.Assert(err, gc.ErrorMatches, "juju restore is in progress - Juju api is off to prevent data loss") 36 c.Assert(caller, gc.IsNil) 37 } 38 39 func (r *restoreRootSuite) TestFindDisallowedMethodWhenPreparing(c *gc.C) { 40 root := apiserver.TestingAboutToRestoreRoot(nil) 41 42 caller, err := root.FindMethod("Service", 3, "Deploy") 43 44 c.Assert(err, gc.ErrorMatches, "juju restore is in progress - Juju functionality is limited to avoid data loss") 45 c.Assert(caller, gc.IsNil) 46 } 47 48 func (r *restoreRootSuite) TestFindDisallowedMethodWhenRestoring(c *gc.C) { 49 root := apiserver.TestingRestoreInProgressRoot(nil) 50 51 caller, err := root.FindMethod("Service", 3, "Deploy") 52 53 c.Assert(err, gc.ErrorMatches, "juju restore is in progress - Juju api is off to prevent data loss") 54 c.Assert(caller, gc.IsNil) 55 }