github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/cmd/juju/service/export_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package service
     5  
     6  import (
     7  	"github.com/juju/cmd"
     8  	"gopkg.in/juju/charmrepo.v2-unstable/csclient"
     9  	"gopkg.in/macaroon-bakery.v1/httpbakery"
    10  
    11  	"github.com/juju/juju/cmd/modelcmd"
    12  )
    13  
    14  // NewSetCommandForTest returns a SetCommand with the api provided as specified.
    15  func NewSetCommandForTest(serviceAPI serviceAPI) cmd.Command {
    16  	return modelcmd.Wrap(&setCommand{
    17  		serviceApi: serviceAPI,
    18  	})
    19  }
    20  
    21  // NewGetCommand returns a GetCommand with the api provided as specified.
    22  func NewGetCommandForTest(api getServiceAPI) cmd.Command {
    23  	return modelcmd.Wrap(&getCommand{
    24  		api: api,
    25  	})
    26  }
    27  
    28  // NewAddUnitCommandForTest returns an AddUnitCommand with the api provided as specified.
    29  func NewAddUnitCommandForTest(api serviceAddUnitAPI) cmd.Command {
    30  	return modelcmd.Wrap(&addUnitCommand{
    31  		api: api,
    32  	})
    33  }
    34  
    35  type Patcher interface {
    36  	PatchValue(dest, value interface{})
    37  }
    38  
    39  func PatchNewCharmStoreClient(s Patcher, url string) {
    40  	s.PatchValue(&newCharmStoreClient, func(bakeryClient *httpbakery.Client) *csclient.Client {
    41  		return csclient.New(csclient.Params{
    42  			URL:          url,
    43  			BakeryClient: bakeryClient,
    44  		})
    45  	})
    46  }