github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/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, parser func(interface{}) (interface{}, error)) *CreateEnvironmentCommand {
    27  	return &CreateEnvironmentCommand{
    28  		api:          api,
    29  		configParser: parser,
    30  	}
    31  }
    32  
    33  // NewEnvironmentsCommand returns a EnvironmentsCommand with the API and userCreds
    34  // provided as specified.
    35  func NewEnvironmentsCommand(envAPI EnvironmentsEnvAPI, sysAPI EnvironmentsSysAPI, userCreds *configstore.APICredentials) *EnvironmentsCommand {
    36  	return &EnvironmentsCommand{
    37  		envAPI:    envAPI,
    38  		sysAPI:    sysAPI,
    39  		userCreds: userCreds,
    40  	}
    41  }
    42  
    43  // NewLoginCommand returns a LoginCommand with the function used to open
    44  // the API connection mocked out.
    45  func NewLoginCommand(apiOpen api.OpenFunc, getUserManager GetUserManagerFunc) *LoginCommand {
    46  	return &LoginCommand{
    47  		apiOpen:        apiOpen,
    48  		getUserManager: getUserManager,
    49  	}
    50  }
    51  
    52  // NewUseEnvironmentCommand returns a UseEnvironmentCommand with the API and
    53  // userCreds provided as specified.
    54  func NewUseEnvironmentCommand(api UseEnvironmentAPI, userCreds *configstore.APICredentials, endpoint *configstore.APIEndpoint) *UseEnvironmentCommand {
    55  	return &UseEnvironmentCommand{
    56  		api:       api,
    57  		userCreds: userCreds,
    58  		endpoint:  endpoint,
    59  	}
    60  }
    61  
    62  // NewRemoveBlocksCommand returns a RemoveBlocksCommand with the function used
    63  // to open the API connection mocked out.
    64  func NewRemoveBlocksCommand(api removeBlocksAPI) *RemoveBlocksCommand {
    65  	return &RemoveBlocksCommand{
    66  		api: api,
    67  	}
    68  }
    69  
    70  // Name makes the private name attribute accessible for tests.
    71  func (c *CreateEnvironmentCommand) Name() string {
    72  	return c.name
    73  }
    74  
    75  // Owner makes the private name attribute accessible for tests.
    76  func (c *CreateEnvironmentCommand) Owner() string {
    77  	return c.owner
    78  }
    79  
    80  // ConfigFile makes the private configFile attribute accessible for tests.
    81  func (c *CreateEnvironmentCommand) ConfigFile() cmd.FileVar {
    82  	return c.configFile
    83  }
    84  
    85  // ConfValues makes the private confValues attribute accessible for tests.
    86  func (c *CreateEnvironmentCommand) ConfValues() map[string]string {
    87  	return c.confValues
    88  }
    89  
    90  // NewDestroyCommand returns a DestroyCommand with the systemmanager and client
    91  // endpoints mocked out.
    92  func NewDestroyCommand(api destroySystemAPI, clientapi destroyClientAPI, apierr error) *DestroyCommand {
    93  	return &DestroyCommand{
    94  		DestroyCommandBase: DestroyCommandBase{
    95  			api:       api,
    96  			clientapi: clientapi,
    97  			apierr:    apierr,
    98  		},
    99  	}
   100  }
   101  
   102  // NewKillCommand returns a KillCommand with the systemmanager and client
   103  // endpoints mocked out.
   104  func NewKillCommand(api destroySystemAPI, clientapi destroyClientAPI, apierr error, dialFunc func(string) (api.Connection, error)) *KillCommand {
   105  	return &KillCommand{
   106  		DestroyCommandBase{
   107  			api:       api,
   108  			clientapi: clientapi,
   109  			apierr:    apierr,
   110  		},
   111  		dialFunc,
   112  	}
   113  }
   114  
   115  // NewListBlocksCommand returns a ListBlocksCommand with the systemmanager
   116  // endpoint mocked out.
   117  func NewListBlocksCommand(api listBlocksAPI, apierr error) *ListBlocksCommand {
   118  	return &ListBlocksCommand{
   119  		api:    api,
   120  		apierr: apierr,
   121  	}
   122  }