-
Notifications
You must be signed in to change notification settings - Fork 5
/
mock_collectionresolver_test.go
155 lines (145 loc) · 5.37 KB
/
mock_collectionresolver_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package gocbcorex
import (
"context"
"sync"
)
// Ensure, that CollectionResolverMock does implement CollectionResolver.
// If this is not the case, regenerate this file with moq.
var _ CollectionResolver = &CollectionResolverMock{}
// CollectionResolverMock is a mock implementation of CollectionResolver.
//
// func TestSomethingThatUsesCollectionResolver(t *testing.T) {
//
// // make and configure a mocked CollectionResolver
// mockedCollectionResolver := &CollectionResolverMock{
// InvalidateCollectionIDFunc: func(ctx context.Context, scopeName string, collectionName string, endpoint string, manifestRev uint64) {
// panic("mock out the InvalidateCollectionID method")
// },
// ResolveCollectionIDFunc: func(ctx context.Context, scopeName string, collectionName string) (uint32, uint64, error) {
// panic("mock out the ResolveCollectionID method")
// },
// }
//
// // use mockedCollectionResolver in code that requires CollectionResolver
// // and then make assertions.
//
// }
type CollectionResolverMock struct {
// InvalidateCollectionIDFunc mocks the InvalidateCollectionID method.
InvalidateCollectionIDFunc func(ctx context.Context, scopeName string, collectionName string, endpoint string, manifestRev uint64)
// ResolveCollectionIDFunc mocks the ResolveCollectionID method.
ResolveCollectionIDFunc func(ctx context.Context, scopeName string, collectionName string) (uint32, uint64, error)
// calls tracks calls to the methods.
calls struct {
// InvalidateCollectionID holds details about calls to the InvalidateCollectionID method.
InvalidateCollectionID []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// ScopeName is the scopeName argument value.
ScopeName string
// CollectionName is the collectionName argument value.
CollectionName string
// Endpoint is the endpoint argument value.
Endpoint string
// ManifestRev is the manifestRev argument value.
ManifestRev uint64
}
// ResolveCollectionID holds details about calls to the ResolveCollectionID method.
ResolveCollectionID []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// ScopeName is the scopeName argument value.
ScopeName string
// CollectionName is the collectionName argument value.
CollectionName string
}
}
lockInvalidateCollectionID sync.RWMutex
lockResolveCollectionID sync.RWMutex
}
// InvalidateCollectionID calls InvalidateCollectionIDFunc.
func (mock *CollectionResolverMock) InvalidateCollectionID(ctx context.Context, scopeName string, collectionName string, endpoint string, manifestRev uint64) {
if mock.InvalidateCollectionIDFunc == nil {
panic("CollectionResolverMock.InvalidateCollectionIDFunc: method is nil but CollectionResolver.InvalidateCollectionID was just called")
}
callInfo := struct {
Ctx context.Context
ScopeName string
CollectionName string
Endpoint string
ManifestRev uint64
}{
Ctx: ctx,
ScopeName: scopeName,
CollectionName: collectionName,
Endpoint: endpoint,
ManifestRev: manifestRev,
}
mock.lockInvalidateCollectionID.Lock()
mock.calls.InvalidateCollectionID = append(mock.calls.InvalidateCollectionID, callInfo)
mock.lockInvalidateCollectionID.Unlock()
mock.InvalidateCollectionIDFunc(ctx, scopeName, collectionName, endpoint, manifestRev)
}
// InvalidateCollectionIDCalls gets all the calls that were made to InvalidateCollectionID.
// Check the length with:
//
// len(mockedCollectionResolver.InvalidateCollectionIDCalls())
func (mock *CollectionResolverMock) InvalidateCollectionIDCalls() []struct {
Ctx context.Context
ScopeName string
CollectionName string
Endpoint string
ManifestRev uint64
} {
var calls []struct {
Ctx context.Context
ScopeName string
CollectionName string
Endpoint string
ManifestRev uint64
}
mock.lockInvalidateCollectionID.RLock()
calls = mock.calls.InvalidateCollectionID
mock.lockInvalidateCollectionID.RUnlock()
return calls
}
// ResolveCollectionID calls ResolveCollectionIDFunc.
func (mock *CollectionResolverMock) ResolveCollectionID(ctx context.Context, scopeName string, collectionName string) (uint32, uint64, error) {
if mock.ResolveCollectionIDFunc == nil {
panic("CollectionResolverMock.ResolveCollectionIDFunc: method is nil but CollectionResolver.ResolveCollectionID was just called")
}
callInfo := struct {
Ctx context.Context
ScopeName string
CollectionName string
}{
Ctx: ctx,
ScopeName: scopeName,
CollectionName: collectionName,
}
mock.lockResolveCollectionID.Lock()
mock.calls.ResolveCollectionID = append(mock.calls.ResolveCollectionID, callInfo)
mock.lockResolveCollectionID.Unlock()
return mock.ResolveCollectionIDFunc(ctx, scopeName, collectionName)
}
// ResolveCollectionIDCalls gets all the calls that were made to ResolveCollectionID.
// Check the length with:
//
// len(mockedCollectionResolver.ResolveCollectionIDCalls())
func (mock *CollectionResolverMock) ResolveCollectionIDCalls() []struct {
Ctx context.Context
ScopeName string
CollectionName string
} {
var calls []struct {
Ctx context.Context
ScopeName string
CollectionName string
}
mock.lockResolveCollectionID.RLock()
calls = mock.calls.ResolveCollectionID
mock.lockResolveCollectionID.RUnlock()
return calls
}