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