github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/cmd/juju/machine/export_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package machine
     5  
     6  import (
     7  	"github.com/juju/cmd"
     8  	"gopkg.in/juju/worker.v1/catacomb"
     9  
    10  	"github.com/juju/juju/api"
    11  	"github.com/juju/juju/cmd/modelcmd"
    12  	"github.com/juju/juju/jujuclient/jujuclienttesting"
    13  	"github.com/juju/juju/storage"
    14  )
    15  
    16  var (
    17  	SSHProvisioner = &sshProvisioner
    18  )
    19  
    20  type AddCommand struct {
    21  	*addCommand
    22  }
    23  
    24  // NewAddCommand returns an AddCommand with the api provided as specified.
    25  func NewAddCommandForTest(api AddMachineAPI, mcAPI ModelConfigAPI, mmAPI MachineManagerAPI) (cmd.Command, *AddCommand) {
    26  	command := &addCommand{
    27  		api:               api,
    28  		machineManagerAPI: mmAPI,
    29  		modelConfigAPI:    mcAPI,
    30  	}
    31  	command.SetClientStore(jujuclienttesting.MinimalStore())
    32  	return modelcmd.Wrap(command), &AddCommand{command}
    33  }
    34  
    35  // NewListCommandForTest returns a listMachineCommand with specified api
    36  func NewListCommandForTest(api statusAPI) cmd.Command {
    37  	command := newListMachinesCommand(api)
    38  	command.SetClientStore(jujuclienttesting.MinimalStore())
    39  	return modelcmd.Wrap(command)
    40  }
    41  
    42  // NewShowCommandForTest returns a showMachineCommand with specified api
    43  func NewShowCommandForTest(api statusAPI) cmd.Command {
    44  	command := newShowMachineCommand(api)
    45  	command.SetClientStore(jujuclienttesting.MinimalStore())
    46  	return modelcmd.Wrap(command)
    47  }
    48  
    49  type RemoveCommand struct {
    50  	*removeCommand
    51  }
    52  
    53  // NewRemoveCommand returns an RemoveCommand with the api provided as specified.
    54  func NewRemoveCommandForTest(apiRoot api.Connection, machineAPI RemoveMachineAPI) (cmd.Command, *RemoveCommand) {
    55  	command := &removeCommand{
    56  		apiRoot:    apiRoot,
    57  		machineAPI: machineAPI,
    58  	}
    59  	command.SetClientStore(jujuclienttesting.MinimalStore())
    60  	return modelcmd.Wrap(command), &RemoveCommand{command}
    61  }
    62  
    63  // NewUpgradeSeriesCommand returns an upgrade series command for test
    64  func NewUpgradeSeriesCommandForTest(upgradeAPI UpgradeMachineSeriesAPI) cmd.Command {
    65  	command := &upgradeSeriesCommand{
    66  		upgradeMachineSeriesClient: upgradeAPI,
    67  	}
    68  	command.plan = catacomb.Plan{
    69  		Site: &command.catacomb,
    70  		Work: func() error { return nil },
    71  	}
    72  	command.SetClientStore(jujuclienttesting.MinimalStore())
    73  	return modelcmd.Wrap(command)
    74  }
    75  
    76  func NewDisksFlag(disks *[]storage.Constraints) *disksFlag {
    77  	return &disksFlag{disks}
    78  }