~juju-qa/ubuntu/yakkety/juju/2.0-beta17

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/apiserver/restrict_upgrades_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-08-26 19:28:00 UTC
  • mfrom: (1.5.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160826192800-b2rgj3da7tgfdca4
* New upstream release 2.0-beta16
* Remove all quilt patches
* Ensure autopkgtests run on LXD upload (LP: #1614724)
* Update debian/copyrights

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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/errors"
 
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/apiserver/params"
 
13
        "github.com/juju/juju/testing"
 
14
)
 
15
 
 
16
type restrictUpgradesSuite struct {
 
17
        testing.BaseSuite
 
18
}
 
19
 
 
20
var _ = gc.Suite(&restrictUpgradesSuite{})
 
21
 
 
22
func (r *restrictUpgradesSuite) TestAllowedMethods(c *gc.C) {
 
23
        root := apiserver.TestingUpgradingRoot(nil)
 
24
        checkAllowed := func(facade, method string) {
 
25
                caller, err := root.FindMethod(facade, 1, method)
 
26
                c.Check(err, jc.ErrorIsNil)
 
27
                c.Check(caller, gc.NotNil)
 
28
        }
 
29
        checkAllowed("Client", "FullStatus")
 
30
        checkAllowed("Client", "AbortCurrentUpgrade")
 
31
        checkAllowed("SSHClient", "PublicAddress")
 
32
        checkAllowed("SSHClient", "Proxy")
 
33
        checkAllowed("Pinger", "Ping")
 
34
}
 
35
 
 
36
func (r *restrictUpgradesSuite) TestFindDisallowedMethod(c *gc.C) {
 
37
        root := apiserver.TestingUpgradingRoot(nil)
 
38
        caller, err := root.FindMethod("Client", 1, "ModelSet")
 
39
        c.Assert(errors.Cause(err), gc.Equals, params.UpgradeInProgressError)
 
40
        c.Assert(caller, gc.IsNil)
 
41
}