github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/authentication/authenticationfakes/fake_token_refresher.go (about)

     1  // This file was generated by counterfeiter
     2  package authenticationfakes
     3  
     4  import (
     5  	"sync"
     6  
     7  	"code.cloudfoundry.org/cli/cf/api/authentication"
     8  )
     9  
    10  type FakeTokenRefresher struct {
    11  	RefreshAuthTokenStub        func() (updatedToken string, apiErr error)
    12  	refreshAuthTokenMutex       sync.RWMutex
    13  	refreshAuthTokenArgsForCall []struct{}
    14  	refreshAuthTokenReturns     struct {
    15  		result1 string
    16  		result2 error
    17  	}
    18  	invocations      map[string][][]interface{}
    19  	invocationsMutex sync.RWMutex
    20  }
    21  
    22  func (fake *FakeTokenRefresher) RefreshAuthToken() (updatedToken string, apiErr error) {
    23  	fake.refreshAuthTokenMutex.Lock()
    24  	fake.refreshAuthTokenArgsForCall = append(fake.refreshAuthTokenArgsForCall, struct{}{})
    25  	fake.recordInvocation("RefreshAuthToken", []interface{}{})
    26  	fake.refreshAuthTokenMutex.Unlock()
    27  	if fake.RefreshAuthTokenStub != nil {
    28  		return fake.RefreshAuthTokenStub()
    29  	} else {
    30  		return fake.refreshAuthTokenReturns.result1, fake.refreshAuthTokenReturns.result2
    31  	}
    32  }
    33  
    34  func (fake *FakeTokenRefresher) RefreshAuthTokenCallCount() int {
    35  	fake.refreshAuthTokenMutex.RLock()
    36  	defer fake.refreshAuthTokenMutex.RUnlock()
    37  	return len(fake.refreshAuthTokenArgsForCall)
    38  }
    39  
    40  func (fake *FakeTokenRefresher) RefreshAuthTokenReturns(result1 string, result2 error) {
    41  	fake.RefreshAuthTokenStub = nil
    42  	fake.refreshAuthTokenReturns = struct {
    43  		result1 string
    44  		result2 error
    45  	}{result1, result2}
    46  }
    47  
    48  func (fake *FakeTokenRefresher) Invocations() map[string][][]interface{} {
    49  	fake.invocationsMutex.RLock()
    50  	defer fake.invocationsMutex.RUnlock()
    51  	fake.refreshAuthTokenMutex.RLock()
    52  	defer fake.refreshAuthTokenMutex.RUnlock()
    53  	return fake.invocations
    54  }
    55  
    56  func (fake *FakeTokenRefresher) recordInvocation(key string, args []interface{}) {
    57  	fake.invocationsMutex.Lock()
    58  	defer fake.invocationsMutex.Unlock()
    59  	if fake.invocations == nil {
    60  		fake.invocations = map[string][][]interface{}{}
    61  	}
    62  	if fake.invocations[key] == nil {
    63  		fake.invocations[key] = [][]interface{}{}
    64  	}
    65  	fake.invocations[key] = append(fake.invocations[key], args)
    66  }
    67  
    68  var _ authentication.TokenRefresher = new(FakeTokenRefresher)