-
Notifications
You must be signed in to change notification settings - Fork 5
/
mock_bucketchecker_test.go
81 lines (74 loc) · 2.16 KB
/
mock_bucketchecker_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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package gocbcorex
import (
"context"
"sync"
)
// Ensure, that BucketCheckerMock does implement BucketChecker.
// If this is not the case, regenerate this file with moq.
var _ BucketChecker = &BucketCheckerMock{}
// BucketCheckerMock is a mock implementation of BucketChecker.
//
// func TestSomethingThatUsesBucketChecker(t *testing.T) {
//
// // make and configure a mocked BucketChecker
// mockedBucketChecker := &BucketCheckerMock{
// HasBucketFunc: func(ctx context.Context, bucketName string) (bool, error) {
// panic("mock out the HasBucket method")
// },
// }
//
// // use mockedBucketChecker in code that requires BucketChecker
// // and then make assertions.
//
// }
type BucketCheckerMock struct {
// HasBucketFunc mocks the HasBucket method.
HasBucketFunc func(ctx context.Context, bucketName string) (bool, error)
// calls tracks calls to the methods.
calls struct {
// HasBucket holds details about calls to the HasBucket method.
HasBucket []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// BucketName is the bucketName argument value.
BucketName string
}
}
lockHasBucket sync.RWMutex
}
// HasBucket calls HasBucketFunc.
func (mock *BucketCheckerMock) HasBucket(ctx context.Context, bucketName string) (bool, error) {
if mock.HasBucketFunc == nil {
panic("BucketCheckerMock.HasBucketFunc: method is nil but BucketChecker.HasBucket was just called")
}
callInfo := struct {
Ctx context.Context
BucketName string
}{
Ctx: ctx,
BucketName: bucketName,
}
mock.lockHasBucket.Lock()
mock.calls.HasBucket = append(mock.calls.HasBucket, callInfo)
mock.lockHasBucket.Unlock()
return mock.HasBucketFunc(ctx, bucketName)
}
// HasBucketCalls gets all the calls that were made to HasBucket.
// Check the length with:
//
// len(mockedBucketChecker.HasBucketCalls())
func (mock *BucketCheckerMock) HasBucketCalls() []struct {
Ctx context.Context
BucketName string
} {
var calls []struct {
Ctx context.Context
BucketName string
}
mock.lockHasBucket.RLock()
calls = mock.calls.HasBucket
mock.lockHasBucket.RUnlock()
return calls
}