github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/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  // NewConfigCommandForTest returns a configCommand with the api
    14  // provided as specified.
    15  func NewConfigCommandForTest(api configCommandAPI) cmd.Command {
    16  	cmd := &configCommand{
    17  		api: api,
    18  	}
    19  	return modelcmd.Wrap(cmd)
    20  }
    21  
    22  // NewDefaultsCommandForTest returns a defaultsCommand with the api provided as specified.
    23  func NewDefaultsCommandForTest(api defaultsCommandAPI, store jujuclient.ClientStore) cmd.Command {
    24  	cmd := &defaultsCommand{
    25  		api: api,
    26  	}
    27  	cmd.SetClientStore(store)
    28  	return modelcmd.WrapController(cmd)
    29  }
    30  
    31  // NewRetryProvisioningCommandForTest returns a RetryProvisioningCommand with the api provided as specified.
    32  func NewRetryProvisioningCommandForTest(api RetryProvisioningAPI) cmd.Command {
    33  	cmd := &retryProvisioningCommand{
    34  		api: api,
    35  	}
    36  	return modelcmd.Wrap(cmd)
    37  }
    38  
    39  // NewShowCommandForTest returns a ShowCommand with the api provided as specified.
    40  func NewShowCommandForTest(api ShowModelAPI, store jujuclient.ClientStore) cmd.Command {
    41  	cmd := &showModelCommand{api: api}
    42  	cmd.SetClientStore(store)
    43  	return modelcmd.Wrap(cmd)
    44  }
    45  
    46  // NewDumpCommandForTest returns a DumpCommand with the api provided as specified.
    47  func NewDumpCommandForTest(api DumpModelAPI, store jujuclient.ClientStore) cmd.Command {
    48  	cmd := &dumpCommand{api: api}
    49  	cmd.SetClientStore(store)
    50  	return modelcmd.WrapController(cmd)
    51  }
    52  
    53  // NewDumpDBCommandForTest returns a DumpDBCommand with the api provided as specified.
    54  func NewDumpDBCommandForTest(api DumpDBAPI, store jujuclient.ClientStore) cmd.Command {
    55  	cmd := &dumpDBCommand{api: api}
    56  	cmd.SetClientStore(store)
    57  	return modelcmd.WrapController(cmd)
    58  }
    59  
    60  // NewDestroyCommandForTest returns a DestroyCommand with the api provided as specified.
    61  func NewDestroyCommandForTest(api DestroyModelAPI, store jujuclient.ClientStore) cmd.Command {
    62  	cmd := &destroyCommand{
    63  		api: api,
    64  	}
    65  	cmd.SetClientStore(store)
    66  	return modelcmd.Wrap(
    67  		cmd,
    68  		modelcmd.WrapSkipDefaultModel,
    69  		modelcmd.WrapSkipModelFlags,
    70  	)
    71  }
    72  
    73  type GrantCommand struct {
    74  	*grantCommand
    75  }
    76  
    77  type RevokeCommand struct {
    78  	*revokeCommand
    79  }
    80  
    81  // NewGrantCommandForTest returns a GrantCommand with the api provided as specified.
    82  func NewGrantCommandForTest(api GrantModelAPI, store jujuclient.ClientStore) (cmd.Command, *GrantCommand) {
    83  	cmd := &grantCommand{
    84  		api: api,
    85  	}
    86  	cmd.SetClientStore(store)
    87  	return modelcmd.WrapController(cmd), &GrantCommand{cmd}
    88  }
    89  
    90  // NewRevokeCommandForTest returns an revokeCommand with the api provided as specified.
    91  func NewRevokeCommandForTest(api RevokeModelAPI, store jujuclient.ClientStore) (cmd.Command, *RevokeCommand) {
    92  	cmd := &revokeCommand{
    93  		api: api,
    94  	}
    95  	cmd.SetClientStore(store)
    96  	return modelcmd.WrapController(cmd), &RevokeCommand{cmd}
    97  }