github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/cmd/juju/system/export_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package system
     5  
     6  import (
     7  	"github.com/juju/cmd"
     8  
     9  	"github.com/juju/juju/api"
    10  	"github.com/juju/juju/environs/configstore"
    11  )
    12  
    13  var (
    14  	SetConfigSpecialCaseDefaults = setConfigSpecialCaseDefaults
    15  	UserCurrent                  = &userCurrent
    16  )
    17  
    18  // NewListCommand returns a ListCommand with the configstore provided as specified.
    19  func NewListCommand(cfgStore configstore.Storage) *ListCommand {
    20  	return &ListCommand{
    21  		cfgStore: cfgStore,
    22  	}
    23  }
    24  
    25  // NewCreateEnvironmentCommand returns a CreateEnvironmentCommand with the api provided as specified.
    26  func NewCreateEnvironmentCommand(api CreateEnvironmentAPI) *CreateEnvironmentCommand {
    27  	return &CreateEnvironmentCommand{
    28  		api: api,
    29  	}
    30  }
    31  
    32  // NewEnvironmentsCommand returns a EnvironmentsCommand with the API and userCreds
    33  // provided as specified.
    34  func NewEnvironmentsCommand(envAPI EnvironmentsEnvAPI, sysAPI EnvironmentsSysAPI, userCreds *configstore.APICredentials) *EnvironmentsCommand {
    35  	return &EnvironmentsCommand{
    36  		envAPI:    envAPI,
    37  		sysAPI:    sysAPI,
    38  		userCreds: userCreds,
    39  	}
    40  }
    41  
    42  // NewLoginCommand returns a LoginCommand with the function used to open
    43  // the API connection mocked out.
    44  func NewLoginCommand(apiOpen api.OpenFunc, getUserManager GetUserManagerFunc) *LoginCommand {
    45  	return &LoginCommand{
    46  		apiOpen:        apiOpen,
    47  		getUserManager: getUserManager,
    48  	}
    49  }
    50  
    51  // NewUseEnvironmentCommand returns a UseEnvironmentCommand with the API and
    52  // userCreds provided as specified.
    53  func NewUseEnvironmentCommand(api UseEnvironmentAPI, userCreds *configstore.APICredentials, endpoint *configstore.APIEndpoint) *UseEnvironmentCommand {
    54  	return &UseEnvironmentCommand{
    55  		api:       api,
    56  		userCreds: userCreds,
    57  		endpoint:  endpoint,
    58  	}
    59  }
    60  
    61  // NewRemoveBlocksCommand returns a RemoveBlocksCommand with the function used
    62  // to open the API connection mocked out.
    63  func NewRemoveBlocksCommand(api removeBlocksAPI) *RemoveBlocksCommand {
    64  	return &RemoveBlocksCommand{
    65  		api: api,
    66  	}
    67  }
    68  
    69  // Name makes the private name attribute accessible for tests.
    70  func (c *CreateEnvironmentCommand) Name() string {
    71  	return c.name
    72  }
    73  
    74  // Owner makes the private name attribute accessible for tests.
    75  func (c *CreateEnvironmentCommand) Owner() string {
    76  	return c.owner
    77  }
    78  
    79  // ConfigFile makes the private configFile attribute accessible for tests.
    80  func (c *CreateEnvironmentCommand) ConfigFile() cmd.FileVar {
    81  	return c.configFile
    82  }
    83  
    84  // ConfValues makes the private confValues attribute accessible for tests.
    85  func (c *CreateEnvironmentCommand) ConfValues() map[string]string {
    86  	return c.confValues
    87  }
    88  
    89  // NewDestroyCommand returns a DestroyCommand with the systemmanager and client
    90  // endpoints mocked out.
    91  func NewDestroyCommand(api destroySystemAPI, clientapi destroyClientAPI, apierr error) *DestroyCommand {
    92  	return &DestroyCommand{
    93  		DestroyCommandBase: DestroyCommandBase{
    94  			api:       api,
    95  			clientapi: clientapi,
    96  			apierr:    apierr,
    97  		},
    98  	}
    99  }
   100  
   101  // NewKillCommand returns a KillCommand with the systemmanager and client
   102  // endpoints mocked out.
   103  func NewKillCommand(api destroySystemAPI, clientapi destroyClientAPI, apierr error, dialFunc func(string) (api.Connection, error)) *KillCommand {
   104  	return &KillCommand{
   105  		DestroyCommandBase{
   106  			api:       api,
   107  			clientapi: clientapi,
   108  			apierr:    apierr,
   109  		},
   110  		dialFunc,
   111  	}
   112  }
   113  
   114  // NewListBlocksCommand returns a ListBlocksCommand with the systemmanager
   115  // endpoint mocked out.
   116  func NewListBlocksCommand(api listBlocksAPI, apierr error) *ListBlocksCommand {
   117  	return &ListBlocksCommand{
   118  		api:    api,
   119  		apierr: apierr,
   120  	}
   121  }