github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/cmd/juju/block/export_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package block 5 6 import ( 7 "github.com/juju/cmd" 8 9 "github.com/juju/juju/apiserver/params" 10 "github.com/juju/juju/cmd/modelcmd" 11 ) 12 13 var ( 14 BlockClient = &getBlockClientAPI 15 UnblockClient = &getUnblockClientAPI 16 ListClient = &getBlockListAPI 17 18 NewDestroyCommand = newDestroyCommand 19 NewRemoveCommand = newRemoveCommand 20 NewChangeCommand = newChangeCommand 21 NewListCommand = newListCommand 22 ) 23 24 type MockBlockClient struct { 25 BlockType string 26 Msg string 27 } 28 29 func (c *MockBlockClient) Close() error { 30 return nil 31 } 32 33 func (c *MockBlockClient) SwitchBlockOn(blockType, msg string) error { 34 c.BlockType = blockType 35 c.Msg = msg 36 return nil 37 } 38 39 func (c *MockBlockClient) SwitchBlockOff(blockType string) error { 40 c.BlockType = blockType 41 c.Msg = "" 42 return nil 43 } 44 45 func (c *MockBlockClient) List() ([]params.Block, error) { 46 if c.BlockType == "" { 47 return []params.Block{}, nil 48 } 49 50 return []params.Block{ 51 params.Block{ 52 Type: c.BlockType, 53 Message: c.Msg, 54 }, 55 }, nil 56 } 57 58 func NewUnblockCommandWithClient(client UnblockClientAPI) cmd.Command { 59 return modelcmd.Wrap(&unblockCommand{client: client}) 60 }