github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/cmd/juju/model/export_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package model
     5  
     6  import (
     7  	"github.com/juju/cmd"
     8  
     9  	"github.com/juju/juju/cmd/modelcmd"
    10  	"github.com/juju/juju/jujuclient"
    11  )
    12  
    13  // NewGetCommandForTest returns a GetCommand with the api provided as specified.
    14  func NewGetCommandForTest(api GetEnvironmentAPI) cmd.Command {
    15  	cmd := &getCommand{
    16  		api: api,
    17  	}
    18  	return modelcmd.Wrap(cmd)
    19  }
    20  
    21  // NewSetCommandForTest returns a SetCommand with the api provided as specified.
    22  func NewSetCommandForTest(api SetModelAPI) cmd.Command {
    23  	cmd := &setCommand{
    24  		api: api,
    25  	}
    26  	return modelcmd.Wrap(cmd)
    27  }
    28  
    29  // NewUnsetCommandForTest returns an UnsetCommand with the api provided as specified.
    30  func NewUnsetCommandForTest(api UnsetEnvironmentAPI) cmd.Command {
    31  	cmd := &unsetCommand{
    32  		api: api,
    33  	}
    34  	return modelcmd.Wrap(cmd)
    35  }
    36  
    37  // NewRetryProvisioningCommandForTest returns a RetryProvisioningCommand with the api provided as specified.
    38  func NewRetryProvisioningCommandForTest(api RetryProvisioningAPI) cmd.Command {
    39  	cmd := &retryProvisioningCommand{
    40  		api: api,
    41  	}
    42  	return modelcmd.Wrap(cmd)
    43  }
    44  
    45  // NewUsersCommandForTest returns a UsersCommand with the api provided as specified.
    46  func NewUsersCommandForTest(api UsersAPI, store jujuclient.ClientStore) cmd.Command {
    47  	cmd := &usersCommand{api: api}
    48  	cmd.SetClientStore(store)
    49  	return modelcmd.Wrap(cmd)
    50  }
    51  
    52  // NewShowCommandForTest returns a ShowCommand with the api provided as specified.
    53  func NewShowCommandForTest(api ShowModelAPI, store jujuclient.ClientStore) cmd.Command {
    54  	cmd := &showModelCommand{api: api}
    55  	cmd.SetClientStore(store)
    56  	return modelcmd.Wrap(cmd)
    57  }
    58  
    59  // NewDestroyCommandForTest returns a DestroyCommand with the api provided as specified.
    60  func NewDestroyCommandForTest(api DestroyEnvironmentAPI, store jujuclient.ClientStore) cmd.Command {
    61  	cmd := &destroyCommand{
    62  		api: api,
    63  	}
    64  	cmd.SetClientStore(store)
    65  	return modelcmd.Wrap(
    66  		cmd,
    67  		modelcmd.ModelSkipDefault,
    68  		modelcmd.ModelSkipFlags,
    69  	)
    70  }
    71  
    72  type GrantCommand struct {
    73  	*grantCommand
    74  }
    75  
    76  type RevokeCommand struct {
    77  	*revokeCommand
    78  }
    79  
    80  // NewGrantCommandForTest returns a GrantCommand with the api provided as specified.
    81  func NewGrantCommandForTest(api GrantModelAPI, store jujuclient.ClientStore) (cmd.Command, *GrantCommand) {
    82  	cmd := &grantCommand{
    83  		api: api,
    84  	}
    85  	cmd.SetClientStore(store)
    86  	return modelcmd.WrapController(cmd), &GrantCommand{cmd}
    87  }
    88  
    89  // NewRevokeCommandForTest returns an revokeCommand with the api provided as specified.
    90  func NewRevokeCommandForTest(api RevokeModelAPI, store jujuclient.ClientStore) (cmd.Command, *RevokeCommand) {
    91  	cmd := &revokeCommand{
    92  		api: api,
    93  	}
    94  	cmd.SetClientStore(store)
    95  	return modelcmd.WrapController(cmd), &RevokeCommand{cmd}
    96  }