-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestrict_migrations_test.go
40 lines (33 loc) · 1.22 KB
/
restrict_migrations_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package apiserver_test
import (
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/apiserver"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/testing"
)
type restrictMigrationsSuite struct {
testing.BaseSuite
}
var _ = gc.Suite(&restrictMigrationsSuite{})
func (r *restrictMigrationsSuite) TestAllowedMethods(c *gc.C) {
root := apiserver.TestingMigratingRoot()
checkAllowed := func(facade, method string, version int) {
caller, err := root.FindMethod(facade, version, method)
c.Check(err, jc.ErrorIsNil)
c.Check(caller, gc.NotNil)
}
checkAllowed("Client", "FullStatus", clientFacadeVersion)
checkAllowed("SSHClient", "PublicAddress", sshClientFacadeVersion)
checkAllowed("SSHClient", "Proxy", sshClientFacadeVersion)
checkAllowed("Pinger", "Ping", pingerFacadeVersion)
}
func (r *restrictMigrationsSuite) TestFindDisallowedMethod(c *gc.C) {
root := apiserver.TestingMigratingRoot()
caller, err := root.FindMethod("Client", clientFacadeVersion, "ModelSet")
c.Assert(errors.Cause(err), gc.Equals, params.MigrationInProgressError)
c.Assert(caller, gc.IsNil)
}