github.com/livekit/protocol@v1.39.3/rpc/rpcfakes/fake_keepalive_pub_sub.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package rpcfakes
     3  
     4  import (
     5  	"context"
     6  	"sync"
     7  
     8  	"github.com/livekit/protocol/livekit"
     9  	"github.com/livekit/protocol/rpc"
    10  	"github.com/livekit/psrpc"
    11  )
    12  
    13  type FakeKeepalivePubSub struct {
    14  	CloseStub        func()
    15  	closeMutex       sync.RWMutex
    16  	closeArgsForCall []struct {
    17  	}
    18  	KillStub        func()
    19  	killMutex       sync.RWMutex
    20  	killArgsForCall []struct {
    21  	}
    22  	PublishPingStub        func(context.Context, livekit.NodeID, *rpc.KeepalivePing) error
    23  	publishPingMutex       sync.RWMutex
    24  	publishPingArgsForCall []struct {
    25  		arg1 context.Context
    26  		arg2 livekit.NodeID
    27  		arg3 *rpc.KeepalivePing
    28  	}
    29  	publishPingReturns struct {
    30  		result1 error
    31  	}
    32  	publishPingReturnsOnCall map[int]struct {
    33  		result1 error
    34  	}
    35  	ShutdownStub        func()
    36  	shutdownMutex       sync.RWMutex
    37  	shutdownArgsForCall []struct {
    38  	}
    39  	SubscribePingStub        func(context.Context, livekit.NodeID) (psrpc.Subscription[*rpc.KeepalivePing], error)
    40  	subscribePingMutex       sync.RWMutex
    41  	subscribePingArgsForCall []struct {
    42  		arg1 context.Context
    43  		arg2 livekit.NodeID
    44  	}
    45  	subscribePingReturns struct {
    46  		result1 psrpc.Subscription[*rpc.KeepalivePing]
    47  		result2 error
    48  	}
    49  	subscribePingReturnsOnCall map[int]struct {
    50  		result1 psrpc.Subscription[*rpc.KeepalivePing]
    51  		result2 error
    52  	}
    53  	invocations      map[string][][]interface{}
    54  	invocationsMutex sync.RWMutex
    55  }
    56  
    57  func (fake *FakeKeepalivePubSub) Close() {
    58  	fake.closeMutex.Lock()
    59  	fake.closeArgsForCall = append(fake.closeArgsForCall, struct {
    60  	}{})
    61  	stub := fake.CloseStub
    62  	fake.recordInvocation("Close", []interface{}{})
    63  	fake.closeMutex.Unlock()
    64  	if stub != nil {
    65  		fake.CloseStub()
    66  	}
    67  }
    68  
    69  func (fake *FakeKeepalivePubSub) CloseCallCount() int {
    70  	fake.closeMutex.RLock()
    71  	defer fake.closeMutex.RUnlock()
    72  	return len(fake.closeArgsForCall)
    73  }
    74  
    75  func (fake *FakeKeepalivePubSub) CloseCalls(stub func()) {
    76  	fake.closeMutex.Lock()
    77  	defer fake.closeMutex.Unlock()
    78  	fake.CloseStub = stub
    79  }
    80  
    81  func (fake *FakeKeepalivePubSub) Kill() {
    82  	fake.killMutex.Lock()
    83  	fake.killArgsForCall = append(fake.killArgsForCall, struct {
    84  	}{})
    85  	stub := fake.KillStub
    86  	fake.recordInvocation("Kill", []interface{}{})
    87  	fake.killMutex.Unlock()
    88  	if stub != nil {
    89  		fake.KillStub()
    90  	}
    91  }
    92  
    93  func (fake *FakeKeepalivePubSub) KillCallCount() int {
    94  	fake.killMutex.RLock()
    95  	defer fake.killMutex.RUnlock()
    96  	return len(fake.killArgsForCall)
    97  }
    98  
    99  func (fake *FakeKeepalivePubSub) KillCalls(stub func()) {
   100  	fake.killMutex.Lock()
   101  	defer fake.killMutex.Unlock()
   102  	fake.KillStub = stub
   103  }
   104  
   105  func (fake *FakeKeepalivePubSub) PublishPing(arg1 context.Context, arg2 livekit.NodeID, arg3 *rpc.KeepalivePing) error {
   106  	fake.publishPingMutex.Lock()
   107  	ret, specificReturn := fake.publishPingReturnsOnCall[len(fake.publishPingArgsForCall)]
   108  	fake.publishPingArgsForCall = append(fake.publishPingArgsForCall, struct {
   109  		arg1 context.Context
   110  		arg2 livekit.NodeID
   111  		arg3 *rpc.KeepalivePing
   112  	}{arg1, arg2, arg3})
   113  	stub := fake.PublishPingStub
   114  	fakeReturns := fake.publishPingReturns
   115  	fake.recordInvocation("PublishPing", []interface{}{arg1, arg2, arg3})
   116  	fake.publishPingMutex.Unlock()
   117  	if stub != nil {
   118  		return stub(arg1, arg2, arg3)
   119  	}
   120  	if specificReturn {
   121  		return ret.result1
   122  	}
   123  	return fakeReturns.result1
   124  }
   125  
   126  func (fake *FakeKeepalivePubSub) PublishPingCallCount() int {
   127  	fake.publishPingMutex.RLock()
   128  	defer fake.publishPingMutex.RUnlock()
   129  	return len(fake.publishPingArgsForCall)
   130  }
   131  
   132  func (fake *FakeKeepalivePubSub) PublishPingCalls(stub func(context.Context, livekit.NodeID, *rpc.KeepalivePing) error) {
   133  	fake.publishPingMutex.Lock()
   134  	defer fake.publishPingMutex.Unlock()
   135  	fake.PublishPingStub = stub
   136  }
   137  
   138  func (fake *FakeKeepalivePubSub) PublishPingArgsForCall(i int) (context.Context, livekit.NodeID, *rpc.KeepalivePing) {
   139  	fake.publishPingMutex.RLock()
   140  	defer fake.publishPingMutex.RUnlock()
   141  	argsForCall := fake.publishPingArgsForCall[i]
   142  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
   143  }
   144  
   145  func (fake *FakeKeepalivePubSub) PublishPingReturns(result1 error) {
   146  	fake.publishPingMutex.Lock()
   147  	defer fake.publishPingMutex.Unlock()
   148  	fake.PublishPingStub = nil
   149  	fake.publishPingReturns = struct {
   150  		result1 error
   151  	}{result1}
   152  }
   153  
   154  func (fake *FakeKeepalivePubSub) PublishPingReturnsOnCall(i int, result1 error) {
   155  	fake.publishPingMutex.Lock()
   156  	defer fake.publishPingMutex.Unlock()
   157  	fake.PublishPingStub = nil
   158  	if fake.publishPingReturnsOnCall == nil {
   159  		fake.publishPingReturnsOnCall = make(map[int]struct {
   160  			result1 error
   161  		})
   162  	}
   163  	fake.publishPingReturnsOnCall[i] = struct {
   164  		result1 error
   165  	}{result1}
   166  }
   167  
   168  func (fake *FakeKeepalivePubSub) Shutdown() {
   169  	fake.shutdownMutex.Lock()
   170  	fake.shutdownArgsForCall = append(fake.shutdownArgsForCall, struct {
   171  	}{})
   172  	stub := fake.ShutdownStub
   173  	fake.recordInvocation("Shutdown", []interface{}{})
   174  	fake.shutdownMutex.Unlock()
   175  	if stub != nil {
   176  		fake.ShutdownStub()
   177  	}
   178  }
   179  
   180  func (fake *FakeKeepalivePubSub) ShutdownCallCount() int {
   181  	fake.shutdownMutex.RLock()
   182  	defer fake.shutdownMutex.RUnlock()
   183  	return len(fake.shutdownArgsForCall)
   184  }
   185  
   186  func (fake *FakeKeepalivePubSub) ShutdownCalls(stub func()) {
   187  	fake.shutdownMutex.Lock()
   188  	defer fake.shutdownMutex.Unlock()
   189  	fake.ShutdownStub = stub
   190  }
   191  
   192  func (fake *FakeKeepalivePubSub) SubscribePing(arg1 context.Context, arg2 livekit.NodeID) (psrpc.Subscription[*rpc.KeepalivePing], error) {
   193  	fake.subscribePingMutex.Lock()
   194  	ret, specificReturn := fake.subscribePingReturnsOnCall[len(fake.subscribePingArgsForCall)]
   195  	fake.subscribePingArgsForCall = append(fake.subscribePingArgsForCall, struct {
   196  		arg1 context.Context
   197  		arg2 livekit.NodeID
   198  	}{arg1, arg2})
   199  	stub := fake.SubscribePingStub
   200  	fakeReturns := fake.subscribePingReturns
   201  	fake.recordInvocation("SubscribePing", []interface{}{arg1, arg2})
   202  	fake.subscribePingMutex.Unlock()
   203  	if stub != nil {
   204  		return stub(arg1, arg2)
   205  	}
   206  	if specificReturn {
   207  		return ret.result1, ret.result2
   208  	}
   209  	return fakeReturns.result1, fakeReturns.result2
   210  }
   211  
   212  func (fake *FakeKeepalivePubSub) SubscribePingCallCount() int {
   213  	fake.subscribePingMutex.RLock()
   214  	defer fake.subscribePingMutex.RUnlock()
   215  	return len(fake.subscribePingArgsForCall)
   216  }
   217  
   218  func (fake *FakeKeepalivePubSub) SubscribePingCalls(stub func(context.Context, livekit.NodeID) (psrpc.Subscription[*rpc.KeepalivePing], error)) {
   219  	fake.subscribePingMutex.Lock()
   220  	defer fake.subscribePingMutex.Unlock()
   221  	fake.SubscribePingStub = stub
   222  }
   223  
   224  func (fake *FakeKeepalivePubSub) SubscribePingArgsForCall(i int) (context.Context, livekit.NodeID) {
   225  	fake.subscribePingMutex.RLock()
   226  	defer fake.subscribePingMutex.RUnlock()
   227  	argsForCall := fake.subscribePingArgsForCall[i]
   228  	return argsForCall.arg1, argsForCall.arg2
   229  }
   230  
   231  func (fake *FakeKeepalivePubSub) SubscribePingReturns(result1 psrpc.Subscription[*rpc.KeepalivePing], result2 error) {
   232  	fake.subscribePingMutex.Lock()
   233  	defer fake.subscribePingMutex.Unlock()
   234  	fake.SubscribePingStub = nil
   235  	fake.subscribePingReturns = struct {
   236  		result1 psrpc.Subscription[*rpc.KeepalivePing]
   237  		result2 error
   238  	}{result1, result2}
   239  }
   240  
   241  func (fake *FakeKeepalivePubSub) SubscribePingReturnsOnCall(i int, result1 psrpc.Subscription[*rpc.KeepalivePing], result2 error) {
   242  	fake.subscribePingMutex.Lock()
   243  	defer fake.subscribePingMutex.Unlock()
   244  	fake.SubscribePingStub = nil
   245  	if fake.subscribePingReturnsOnCall == nil {
   246  		fake.subscribePingReturnsOnCall = make(map[int]struct {
   247  			result1 psrpc.Subscription[*rpc.KeepalivePing]
   248  			result2 error
   249  		})
   250  	}
   251  	fake.subscribePingReturnsOnCall[i] = struct {
   252  		result1 psrpc.Subscription[*rpc.KeepalivePing]
   253  		result2 error
   254  	}{result1, result2}
   255  }
   256  
   257  func (fake *FakeKeepalivePubSub) Invocations() map[string][][]interface{} {
   258  	fake.invocationsMutex.RLock()
   259  	defer fake.invocationsMutex.RUnlock()
   260  	fake.closeMutex.RLock()
   261  	defer fake.closeMutex.RUnlock()
   262  	fake.killMutex.RLock()
   263  	defer fake.killMutex.RUnlock()
   264  	fake.publishPingMutex.RLock()
   265  	defer fake.publishPingMutex.RUnlock()
   266  	fake.shutdownMutex.RLock()
   267  	defer fake.shutdownMutex.RUnlock()
   268  	fake.subscribePingMutex.RLock()
   269  	defer fake.subscribePingMutex.RUnlock()
   270  	copiedInvocations := map[string][][]interface{}{}
   271  	for key, value := range fake.invocations {
   272  		copiedInvocations[key] = value
   273  	}
   274  	return copiedInvocations
   275  }
   276  
   277  func (fake *FakeKeepalivePubSub) recordInvocation(key string, args []interface{}) {
   278  	fake.invocationsMutex.Lock()
   279  	defer fake.invocationsMutex.Unlock()
   280  	if fake.invocations == nil {
   281  		fake.invocations = map[string][][]interface{}{}
   282  	}
   283  	if fake.invocations[key] == nil {
   284  		fake.invocations[key] = [][]interface{}{}
   285  	}
   286  	fake.invocations[key] = append(fake.invocations[key], args)
   287  }
   288  
   289  var _ rpc.KeepalivePubSub = new(FakeKeepalivePubSub)