github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/cmd/juju/user/export_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package user
     5  
     6  import (
     7  	"github.com/juju/cmd"
     8  	"github.com/juju/utils/clock"
     9  
    10  	"github.com/juju/juju/api"
    11  	"github.com/juju/juju/cmd/modelcmd"
    12  	"github.com/juju/juju/juju"
    13  	"github.com/juju/juju/jujuclient"
    14  )
    15  
    16  type AddCommand struct {
    17  	*addCommand
    18  }
    19  
    20  type RemoveCommand struct {
    21  	*removeCommand
    22  }
    23  
    24  type ChangePasswordCommand struct {
    25  	*changePasswordCommand
    26  }
    27  
    28  type LoginCommand struct {
    29  	*loginCommand
    30  }
    31  
    32  type LogoutCommand struct {
    33  	*logoutCommand
    34  }
    35  
    36  type DisenableUserBase struct {
    37  	*disenableUserBase
    38  }
    39  
    40  func NewAddCommandForTest(api AddUserAPI, store jujuclient.ClientStore, modelAPI modelcmd.ModelAPI) (cmd.Command, *AddCommand) {
    41  	c := &addCommand{api: api}
    42  	c.SetClientStore(store)
    43  	c.SetModelAPI(modelAPI)
    44  	return modelcmd.WrapController(c), &AddCommand{c}
    45  }
    46  
    47  func NewRemoveCommandForTest(api RemoveUserAPI, store jujuclient.ClientStore) (cmd.Command, *RemoveCommand) {
    48  	c := &removeCommand{api: api}
    49  	c.SetClientStore(store)
    50  	return modelcmd.WrapController(c), &RemoveCommand{c}
    51  }
    52  
    53  func NewShowUserCommandForTest(api UserInfoAPI, store jujuclient.ClientStore) cmd.Command {
    54  	cmd := &infoCommand{infoCommandBase: infoCommandBase{
    55  		clock: clock.WallClock,
    56  		api:   api}}
    57  	cmd.SetClientStore(store)
    58  	return modelcmd.WrapController(cmd)
    59  }
    60  
    61  // NewChangePasswordCommand returns a ChangePasswordCommand with the api
    62  // and writer provided as specified.
    63  func NewChangePasswordCommandForTest(
    64  	newAPIConnection func(juju.NewAPIConnectionParams) (api.Connection, error),
    65  	api ChangePasswordAPI,
    66  	store jujuclient.ClientStore,
    67  ) (cmd.Command, *ChangePasswordCommand) {
    68  	c := &changePasswordCommand{
    69  		newAPIConnection: newAPIConnection,
    70  		api:              api,
    71  	}
    72  	c.SetClientStore(store)
    73  	return modelcmd.WrapController(c), &ChangePasswordCommand{c}
    74  }
    75  
    76  // NewLoginCommand returns a LoginCommand with the api
    77  // and writer provided as specified.
    78  func NewLoginCommandForTest(
    79  	newLoginAPI func(juju.NewAPIConnectionParams) (LoginAPI, ConnectionAPI, error),
    80  	store jujuclient.ClientStore,
    81  ) (cmd.Command, *LoginCommand) {
    82  	c := &loginCommand{newLoginAPI: newLoginAPI}
    83  	c.SetClientStore(store)
    84  	return modelcmd.WrapController(c), &LoginCommand{c}
    85  }
    86  
    87  // NewLogoutCommand returns a LogoutCommand with the api
    88  // and writer provided as specified.
    89  func NewLogoutCommandForTest(store jujuclient.ClientStore) (cmd.Command, *LogoutCommand) {
    90  	c := &logoutCommand{}
    91  	c.SetClientStore(store)
    92  	return modelcmd.WrapController(c), &LogoutCommand{c}
    93  }
    94  
    95  // NewDisableCommand returns a DisableCommand with the api provided as
    96  // specified.
    97  func NewDisableCommandForTest(api disenableUserAPI, store jujuclient.ClientStore) (cmd.Command, *DisenableUserBase) {
    98  	c := &disableCommand{disenableUserBase{api: api}}
    99  	c.SetClientStore(store)
   100  	return modelcmd.WrapController(c), &DisenableUserBase{&c.disenableUserBase}
   101  }
   102  
   103  // NewEnableCommand returns a EnableCommand with the api provided as
   104  // specified.
   105  func NewEnableCommandForTest(api disenableUserAPI, store jujuclient.ClientStore) (cmd.Command, *DisenableUserBase) {
   106  	c := &enableCommand{disenableUserBase{api: api}}
   107  	c.SetClientStore(store)
   108  	return modelcmd.WrapController(c), &DisenableUserBase{&c.disenableUserBase}
   109  }
   110  
   111  // NewListCommand returns a ListCommand with the api provided as specified.
   112  func NewListCommandForTest(api UserInfoAPI, modelAPI modelUsersAPI, store jujuclient.ClientStore, clock clock.Clock) cmd.Command {
   113  	c := &listCommand{
   114  		infoCommandBase: infoCommandBase{
   115  			clock: clock,
   116  			api:   api,
   117  		},
   118  		modelUserAPI: modelAPI,
   119  	}
   120  	c.SetClientStore(store)
   121  	return modelcmd.WrapController(c)
   122  }
   123  
   124  // NewWhoAmICommandForTest returns a whoAMI command with a mock store.
   125  func NewWhoAmICommandForTest(store jujuclient.ClientStore) cmd.Command {
   126  	c := &whoAmICommand{store: store}
   127  	return c
   128  }