forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
block_test.go
58 lines (44 loc) · 1.46 KB
/
block_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package featuretests
import (
"fmt"
"github.com/juju/cmd/v3/cmdtesting"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/api/client/block"
"github.com/juju/juju/core/model"
jujutesting "github.com/juju/juju/juju/testing"
)
type blockSuite struct {
jujutesting.JujuConnSuite
blockClient *block.Client
}
func (s *blockSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
s.blockClient = block.NewClient(s.APIState)
c.Assert(s.blockClient, gc.NotNil)
s.AddCleanup(func(*gc.C) {
s.blockClient.ClientFacade.Close()
})
}
func (s *blockSuite) TestBlockFacadeCall(c *gc.C) {
found, err := s.blockClient.List()
c.Assert(err, jc.ErrorIsNil)
c.Assert(found, gc.HasLen, 0)
}
func (s *blockSuite) TestBlockedMessage(c *gc.C) {
// Block operation
s.blockClient.SwitchBlockOn(fmt.Sprintf("%v", model.BlockChange), "TestBlockedMessage")
ctx, err := runCommand(c, "resolved", "multi-series/2")
// Whenever Juju blocks are enabled, the operations that are blocked will be expected to err
// out silently.
c.Assert(err, gc.ErrorMatches, "cmd: error out silently")
c.Assert(cmdtesting.Stdout(ctx), gc.Equals, "")
c.Assert(cmdtesting.Stderr(ctx), gc.Equals, `
ERROR TestBlockedMessage (operation is blocked)
All operations that change model have been disabled for the current model.
To enable changes, run
juju enable-command all
`[1:])
}