github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/cmd/juju/crossmodel/export_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package crossmodel
     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  var (
    14  	Max          = max
    15  	DescAt       = descAt
    16  	BreakLines   = breakLines
    17  	ColumnWidth  = columnWidth
    18  	BreakOneWord = breakOneWord
    19  )
    20  
    21  func noOpRefresh(jujuclient.ClientStore, string) error {
    22  	return nil
    23  }
    24  
    25  func NewOfferCommandForTest(
    26  	store jujuclient.ClientStore,
    27  	api OfferAPI,
    28  ) cmd.Command {
    29  	aCmd := &offerCommand{
    30  		newAPIFunc: func() (OfferAPI, error) {
    31  			return api, nil
    32  		},
    33  		refreshModels: noOpRefresh,
    34  	}
    35  	aCmd.SetClientStore(store)
    36  	return modelcmd.WrapController(aCmd)
    37  }
    38  
    39  func NewShowEndpointsCommandForTest(store jujuclient.ClientStore, api ShowAPI) cmd.Command {
    40  	aCmd := &showCommand{newAPIFunc: func(controllerName string) (ShowAPI, error) {
    41  		return api, nil
    42  	}}
    43  	aCmd.SetClientStore(store)
    44  	return modelcmd.WrapController(aCmd)
    45  }
    46  
    47  func NewListEndpointsCommandForTest(store jujuclient.ClientStore, api ListAPI) cmd.Command {
    48  	aCmd := &listCommand{
    49  		newAPIFunc: func() (ListAPI, error) {
    50  			return api, nil
    51  		},
    52  		refreshModels: noOpRefresh,
    53  	}
    54  	aCmd.SetClientStore(store)
    55  	return modelcmd.Wrap(aCmd)
    56  }
    57  
    58  func NewFindEndpointsCommandForTest(store jujuclient.ClientStore, api FindAPI) cmd.Command {
    59  	aCmd := &findCommand{newAPIFunc: func(controllerName string) (FindAPI, error) {
    60  		return api, nil
    61  	}}
    62  	aCmd.SetClientStore(store)
    63  	return modelcmd.WrapController(aCmd)
    64  }
    65  
    66  func NewRemoveCommandForTest(store jujuclient.ClientStore, api RemoveAPI) cmd.Command {
    67  	aCmd := &removeCommand{newAPIFunc: func(controllerName string) (RemoveAPI, error) {
    68  		return api, nil
    69  	}}
    70  	aCmd.SetClientStore(store)
    71  	return modelcmd.WrapController(aCmd)
    72  }