github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/cf/ssh/sshfakes/fake_secure_dialer.go (about)

     1  // This file was generated by counterfeiter
     2  package sshfakes
     3  
     4  import (
     5  	"sync"
     6  
     7  	"code.cloudfoundry.org/cli/cf/ssh"
     8  	"golang.org/x/crypto/ssh"
     9  )
    10  
    11  type FakeSecureDialer struct {
    12  	DialStub        func(network, address string, config *ssh.ClientConfig) (sshCmd.SecureClient, error)
    13  	dialMutex       sync.RWMutex
    14  	dialArgsForCall []struct {
    15  		network string
    16  		address string
    17  		config  *ssh.ClientConfig
    18  	}
    19  	dialReturns struct {
    20  		result1 sshCmd.SecureClient
    21  		result2 error
    22  	}
    23  	invocations      map[string][][]interface{}
    24  	invocationsMutex sync.RWMutex
    25  }
    26  
    27  func (fake *FakeSecureDialer) Dial(network string, address string, config *ssh.ClientConfig) (sshCmd.SecureClient, error) {
    28  	fake.dialMutex.Lock()
    29  	fake.dialArgsForCall = append(fake.dialArgsForCall, struct {
    30  		network string
    31  		address string
    32  		config  *ssh.ClientConfig
    33  	}{network, address, config})
    34  	fake.recordInvocation("Dial", []interface{}{network, address, config})
    35  	fake.dialMutex.Unlock()
    36  	if fake.DialStub != nil {
    37  		return fake.DialStub(network, address, config)
    38  	} else {
    39  		return fake.dialReturns.result1, fake.dialReturns.result2
    40  	}
    41  }
    42  
    43  func (fake *FakeSecureDialer) DialCallCount() int {
    44  	fake.dialMutex.RLock()
    45  	defer fake.dialMutex.RUnlock()
    46  	return len(fake.dialArgsForCall)
    47  }
    48  
    49  func (fake *FakeSecureDialer) DialArgsForCall(i int) (string, string, *ssh.ClientConfig) {
    50  	fake.dialMutex.RLock()
    51  	defer fake.dialMutex.RUnlock()
    52  	return fake.dialArgsForCall[i].network, fake.dialArgsForCall[i].address, fake.dialArgsForCall[i].config
    53  }
    54  
    55  func (fake *FakeSecureDialer) DialReturns(result1 sshCmd.SecureClient, result2 error) {
    56  	fake.DialStub = nil
    57  	fake.dialReturns = struct {
    58  		result1 sshCmd.SecureClient
    59  		result2 error
    60  	}{result1, result2}
    61  }
    62  
    63  func (fake *FakeSecureDialer) Invocations() map[string][][]interface{} {
    64  	fake.invocationsMutex.RLock()
    65  	defer fake.invocationsMutex.RUnlock()
    66  	fake.dialMutex.RLock()
    67  	defer fake.dialMutex.RUnlock()
    68  	return fake.invocations
    69  }
    70  
    71  func (fake *FakeSecureDialer) recordInvocation(key string, args []interface{}) {
    72  	fake.invocationsMutex.Lock()
    73  	defer fake.invocationsMutex.Unlock()
    74  	if fake.invocations == nil {
    75  		fake.invocations = map[string][][]interface{}{}
    76  	}
    77  	if fake.invocations[key] == nil {
    78  		fake.invocations[key] = [][]interface{}{}
    79  	}
    80  	fake.invocations[key] = append(fake.invocations[key], args)
    81  }
    82  
    83  var _ sshCmd.SecureDialer = new(FakeSecureDialer)