github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/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 // NewDisableCommandForTest returns a new disable command with the 14 // apiFunc specified to return the args. 15 func NewDisableCommandForTest(api blockClientAPI, err error) cmd.Command { 16 return modelcmd.Wrap(&disableCommand{ 17 apiFunc: func(_ newAPIRoot) (blockClientAPI, error) { 18 return api, err 19 }, 20 }) 21 } 22 23 // NewEnableCommandForTest returns a new enable command with the 24 // apiFunc specified to return the args. 25 func NewEnableCommandForTest(api unblockClientAPI, err error) cmd.Command { 26 return modelcmd.Wrap(&enableCommand{ 27 apiFunc: func(_ newAPIRoot) (unblockClientAPI, error) { 28 return api, err 29 }, 30 }) 31 } 32 33 type listMockAPI interface { 34 blockListAPI 35 // Can't include two interfaces that specify the same method 36 ListBlockedModels() ([]params.ModelBlockInfo, error) 37 } 38 39 // NewListCommandForTest returns a new list command with the 40 // apiFunc specified to return the args. 41 func NewListCommandForTest(api listMockAPI, err error) cmd.Command { 42 return modelcmd.Wrap(&listCommand{ 43 apiFunc: func(_ newAPIRoot) (blockListAPI, error) { 44 return api, err 45 }, 46 controllerAPIFunc: func(_ newControllerAPIRoot) (controllerListAPI, error) { 47 return api, err 48 }, 49 }) 50 }