Skip to content

Commit 0cfa9d2

Browse files
committed
Fix the other tests.
1 parent 170112b commit 0cfa9d2

12 files changed

+21
-53
lines changed

cmd/juju/block/disablecommand.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Examples:
8484
juju disable-command destroy-model "Check with SA before destruction."
8585
8686
# To prevent the machines, applications, units and relations from being removed:
87-
juju disable-command remove-object
87+
juju disable-command remove-object
8888
8989
# To prevent changes to the model:
9090
juju disable-command all "Model locked down"

cmd/juju/commands/main_test.go

+5-20
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
gc "gopkg.in/check.v1"
2424

2525
"github.com/juju/juju/cmd/juju/application"
26-
"github.com/juju/juju/cmd/juju/block"
2726
"github.com/juju/juju/cmd/juju/cloud"
2827
"github.com/juju/juju/cmd/modelcmd"
2928
cmdtesting "github.com/juju/juju/cmd/testing"
@@ -52,10 +51,6 @@ func syncToolsHelpText() string {
5251
return cmdtesting.HelpText(newSyncToolsCommand(), "juju sync-tools")
5352
}
5453

55-
func blockHelpText() string {
56-
return cmdtesting.HelpText(block.NewSuperBlockCommand(), "juju block")
57-
}
58-
5954
func (s *MainSuite) TestRunMain(c *gc.C) {
6055
// The test array structure needs to be inline here as some of the
6156
// expected values below use deployHelpText(). This constructs the deploy
@@ -132,18 +127,7 @@ func (s *MainSuite) TestRunMain(c *gc.C) {
132127
Arch: arch.HostArch(),
133128
Series: series.HostSeries(),
134129
}.String() + "\n",
135-
}, {
136-
summary: "check block command registered properly",
137-
args: []string{"block", "-h"},
138-
code: 0,
139-
out: blockHelpText(),
140-
}, {
141-
summary: "check unblock command registered properly",
142-
args: []string{"unblock"},
143-
code: 0,
144-
out: "error: must specify one of [destroy-model | remove-object | all-changes] to unblock\n",
145-
},
146-
} {
130+
}} {
147131
c.Logf("test %d: %s", i, t.summary)
148132
out := badrun(c, t.code, t.args...)
149133
c.Assert(out, gc.Equals, t.out)
@@ -418,7 +402,6 @@ var commandNames = []string{
418402
"allocate",
419403
"autoload-credentials",
420404
"backups",
421-
"block",
422405
"bootstrap",
423406
"budgets",
424407
"cached-images",
@@ -437,9 +420,12 @@ var commandNames = []string{
437420
"deploy",
438421
"destroy-controller",
439422
"destroy-model",
423+
"disable-command",
440424
"disable-user",
425+
"disabled-commands",
441426
"download-backup",
442427
"enable-ha",
428+
"enable-command",
443429
"enable-user",
444430
"expose",
445431
"get-config",
@@ -455,13 +441,13 @@ var commandNames = []string{
455441
"kill-controller",
456442
"list-actions",
457443
"list-agreements",
458-
"list-all-blocks",
459444
"list-backups",
460445
"list-budgets",
461446
"list-cached-images",
462447
"list-clouds",
463448
"list-controllers",
464449
"list-credentials",
450+
"list-disabled-commands",
465451
"list-machines",
466452
"list-models",
467453
"list-plans",
@@ -531,7 +517,6 @@ var commandNames = []string{
531517
"subnets",
532518
"switch",
533519
"sync-tools",
534-
"unblock",
535520
"unexpose",
536521
"update-allocation",
537522
"upload-backup",

cmd/juju/commands/run_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (s *RunSuite) TestBlockRunForMachineAndUnit(c *gc.C) {
277277
c.Assert(err, gc.ErrorMatches, cmd.ErrSilent.Error())
278278
// msg is logged
279279
stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
280-
c.Check(stripped, gc.Matches, ".*To unblock changes.*")
280+
c.Check(stripped, gc.Matches, ".*To enable changes.*")
281281
}
282282

283283
func (s *RunSuite) TestAllMachines(c *gc.C) {
@@ -337,7 +337,7 @@ func (s *RunSuite) TestBlockAllMachines(c *gc.C) {
337337
c.Assert(err, gc.ErrorMatches, cmd.ErrSilent.Error())
338338
// msg is logged
339339
stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
340-
c.Check(stripped, gc.Matches, ".*To unblock changes.*")
340+
c.Check(stripped, gc.Matches, ".*To enable changes.*")
341341
}
342342

343343
func (s *RunSuite) TestSingleResponse(c *gc.C) {

cmd/juju/commands/sshkeys_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (s *SSHKeysSuite) TestHelpImport(c *gc.C) {
5252

5353
type keySuiteBase struct {
5454
jujutesting.JujuConnSuite
55-
jujutesting.CmdBlockHelper
55+
coretesting.CmdBlockHelper
5656
}
5757

5858
func (s *keySuiteBase) SetUpSuite(c *gc.C) {
@@ -62,7 +62,7 @@ func (s *keySuiteBase) SetUpSuite(c *gc.C) {
6262

6363
func (s *keySuiteBase) SetUpTest(c *gc.C) {
6464
s.JujuConnSuite.SetUpTest(c)
65-
s.CmdBlockHelper = jujutesting.NewCmdBlockHelper(s.APIState)
65+
s.CmdBlockHelper = coretesting.NewCmdBlockHelper(s.APIState)
6666
c.Assert(s.CmdBlockHelper, gc.NotNil)
6767
s.AddCleanup(func(*gc.C) { s.CmdBlockHelper.Close() })
6868
}

cmd/juju/commands/upgradejuju_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ func (s *UpgradeJujuSuite) TestBlockUpgradeInProgress(c *gc.C) {
820820
// Block operation
821821
s.BlockAllChanges(c, "TestBlockUpgradeInProgress")
822822
err = modelcmd.Wrap(cmd).Run(coretesting.Context(c))
823-
s.AssertBlocked(c, err, ".*To unblock changes.*")
823+
s.AssertBlocked(c, err, ".*To enable changes.*")
824824
}
825825

826826
func (s *UpgradeJujuSuite) TestResetPreviousUpgrade(c *gc.C) {

cmd/juju/common/controller.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ var (
6262
blockAPI = getBlockAPI
6363
)
6464

65+
type listBlocksAPI interface {
66+
List() ([]params.Block, error)
67+
Close() error
68+
}
69+
6570
// getBlockAPI returns a block api for listing blocks.
66-
func getBlockAPI(c *modelcmd.ModelCommandBase) (*block.Client, error) {
71+
func getBlockAPI(c *modelcmd.ModelCommandBase) (listBlocksAPI, error) {
6772
root, err := c.NewAPIRoot()
6873
if err != nil {
6974
return nil, errors.Trace(err)

cmd/juju/common/controller_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
gc "gopkg.in/check.v1"
1313

1414
"github.com/juju/juju/apiserver/params"
15-
"github.com/juju/juju/cmd/juju/block"
1615
"github.com/juju/juju/cmd/modelcmd"
1716
cmdtesting "github.com/juju/juju/cmd/testing"
1817
"github.com/juju/juju/jujuclient/jujuclienttesting"
@@ -30,7 +29,7 @@ type controllerSuite struct {
3029

3130
func (s *controllerSuite) SetUpTest(c *gc.C) {
3231
s.mockBlockClient = &mockBlockClient{}
33-
s.PatchValue(&blockAPI, func(*modelcmd.ModelCommandBase) (block.BlockListAPI, error) {
32+
s.PatchValue(&blockAPI, func(*modelcmd.ModelCommandBase) (listBlocksAPI, error) {
3433
err := s.mockBlockClient.loginError
3534
if err != nil {
3635
s.mockBlockClient.loginError = nil

cmd/juju/model/destroy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,5 @@ func (s *DestroySuite) TestDestroyCommandConfirmation(c *gc.C) {
193193
func (s *DestroySuite) TestBlockedDestroy(c *gc.C) {
194194
s.api.err = &params.Error{Code: params.CodeOperationBlocked}
195195
s.runDestroyCommand(c, "test2", "-y")
196-
c.Check(c.GetTestLog(), jc.Contains, "To remove the block")
196+
c.Check(c.GetTestLog(), jc.Contains, "To enable the command")
197197
}

cmd/juju/model/grantrevoke_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (s *grantRevokeSuite) TestBlockGrant(c *gc.C) {
8585
s.fake.err = &params.Error{Code: params.CodeOperationBlocked}
8686
_, err := s.run(c, "sam", "read", "foo")
8787
c.Assert(err, gc.Equals, cmd.ErrSilent)
88-
c.Check(c.GetTestLog(), jc.Contains, "To unblock changes")
88+
c.Check(c.GetTestLog(), jc.Contains, "To enable changes")
8989
}
9090

9191
type grantSuite struct {

cmd/juju/user/add_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (s *UserAddCommandSuite) TestBlockAddUser(c *gc.C) {
128128
c.Assert(err, gc.ErrorMatches, cmd.ErrSilent.Error())
129129
// msg is logged
130130
stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
131-
c.Check(stripped, gc.Matches, ".*To unblock changes.*")
131+
c.Check(stripped, gc.Matches, ".*To enable changes.*")
132132
}
133133

134134
func (s *UserAddCommandSuite) TestAddUserErrorResponse(c *gc.C) {

featuretests/block_test.go

-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
package featuretests
55

66
import (
7-
"github.com/juju/errors"
87
jc "github.com/juju/testing/checkers"
98
gc "gopkg.in/check.v1"
109

1110
"github.com/juju/juju/api/block"
1211
jujutesting "github.com/juju/juju/juju/testing"
13-
"github.com/juju/juju/state"
1412
)
1513

1614
type blockSuite struct {
@@ -32,8 +30,3 @@ func (s *blockSuite) TestBlockFacadeCall(c *gc.C) {
3230
c.Assert(err, jc.ErrorIsNil)
3331
c.Assert(found, gc.HasLen, 0)
3432
}
35-
36-
func (s *blockSuite) TestBlockFacadeCallGettingErrors(c *gc.C) {
37-
err := s.blockClient.SwitchBlockOff(state.DestroyBlock.String())
38-
c.Assert(errors.Cause(err), gc.ErrorMatches, `.*is already OFF.*`)
39-
}

featuretests/cmd_juju_controller_test.go

-14
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
package featuretests
55

66
import (
7-
"fmt"
87
"os"
98
"reflect"
10-
"strings"
119
"time"
1210

1311
"github.com/juju/cmd"
@@ -299,18 +297,6 @@ func (s *cmdControllerSuite) TestControllerKill(c *gc.C) {
299297
c.Assert(err, jc.Satisfies, errors.IsNotFound)
300298
}
301299

302-
func (s *cmdControllerSuite) TestListBlocks(c *gc.C) {
303-
s.State.SwitchBlockOn(state.DestroyBlock, "TestBlockDestroyModel")
304-
s.State.SwitchBlockOn(state.ChangeBlock, "TestChangeBlock")
305-
306-
ctx := s.run(c, "list-all-blocks", "--format", "json")
307-
expected := fmt.Sprintf(`[{"name":"controller","model-uuid":"%s","owner-tag":"%s","blocks":["BlockDestroy","BlockChange"]}]`,
308-
s.State.ModelUUID(), s.AdminUserTag(c).String())
309-
310-
strippedOut := strings.Replace(testing.Stdout(ctx), "\n", "", -1)
311-
c.Check(strippedOut, gc.Equals, expected)
312-
}
313-
314300
func (s *cmdControllerSuite) TestSystemKillCallsEnvironDestroyOnHostedEnviron(c *gc.C) {
315301
st := s.Factory.MakeModel(c, &factory.ModelParams{
316302
Name: "foo",

0 commit comments

Comments
 (0)