github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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 9 "github.com/juju/juju/cmd/modelcmd" 10 "github.com/juju/juju/juju" 11 "github.com/juju/juju/jujuclient" 12 ) 13 14 type AddCommand struct { 15 *addCommand 16 } 17 18 type ChangePasswordCommand struct { 19 *changePasswordCommand 20 } 21 22 type LoginCommand struct { 23 *loginCommand 24 } 25 26 type LogoutCommand struct { 27 *logoutCommand 28 } 29 30 type DisenableUserBase struct { 31 *disenableUserBase 32 } 33 34 func NewAddCommandForTest(api AddUserAPI, store jujuclient.ClientStore, modelApi modelcmd.ModelAPI) (cmd.Command, *AddCommand) { 35 c := &addCommand{api: api} 36 c.SetClientStore(store) 37 c.SetModelApi(modelApi) 38 return modelcmd.WrapController(c), &AddCommand{c} 39 } 40 41 func NewShowUserCommandForTest(api UserInfoAPI, store jujuclient.ClientStore) cmd.Command { 42 cmd := &infoCommand{infoCommandBase: infoCommandBase{api: api}} 43 cmd.SetClientStore(store) 44 return modelcmd.WrapController(cmd) 45 } 46 47 // NewChangePasswordCommand returns a ChangePasswordCommand with the api 48 // and writer provided as specified. 49 func NewChangePasswordCommandForTest(api ChangePasswordAPI, store jujuclient.ClientStore) (cmd.Command, *ChangePasswordCommand) { 50 c := &changePasswordCommand{api: api} 51 c.SetClientStore(store) 52 return modelcmd.WrapController(c), &ChangePasswordCommand{c} 53 } 54 55 // NewLoginCommand returns a LoginCommand with the api 56 // and writer provided as specified. 57 func NewLoginCommandForTest( 58 newLoginAPI func(juju.NewAPIConnectionParams) (LoginAPI, error), 59 store jujuclient.ClientStore, 60 ) (cmd.Command, *LoginCommand) { 61 c := &loginCommand{newLoginAPI: newLoginAPI} 62 c.SetClientStore(store) 63 return modelcmd.WrapController(c), &LoginCommand{c} 64 } 65 66 // NewLogoutCommand returns a LogoutCommand with the api 67 // and writer provided as specified. 68 func NewLogoutCommandForTest(store jujuclient.ClientStore) (cmd.Command, *LogoutCommand) { 69 c := &logoutCommand{} 70 c.SetClientStore(store) 71 return modelcmd.WrapController(c), &LogoutCommand{c} 72 } 73 74 // NewDisableCommand returns a DisableCommand with the api provided as 75 // specified. 76 func NewDisableCommandForTest(api disenableUserAPI, store jujuclient.ClientStore) (cmd.Command, *DisenableUserBase) { 77 c := &disableCommand{disenableUserBase{api: api}} 78 c.SetClientStore(store) 79 return modelcmd.WrapController(c), &DisenableUserBase{&c.disenableUserBase} 80 } 81 82 // NewEnableCommand returns a EnableCommand with the api provided as 83 // specified. 84 func NewEnableCommandForTest(api disenableUserAPI, store jujuclient.ClientStore) (cmd.Command, *DisenableUserBase) { 85 c := &enableCommand{disenableUserBase{api: api}} 86 c.SetClientStore(store) 87 return modelcmd.WrapController(c), &DisenableUserBase{&c.disenableUserBase} 88 } 89 90 // NewListCommand returns a ListCommand with the api provided as specified. 91 func NewListCommandForTest(api UserInfoAPI, store jujuclient.ClientStore) cmd.Command { 92 c := &listCommand{infoCommandBase: infoCommandBase{api: api}} 93 c.SetClientStore(store) 94 return modelcmd.WrapController(c) 95 }