-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_provider_mock.go
129 lines (119 loc) · 3.87 KB
/
git_provider_mock.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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package promote
import (
"sync"
)
// Ensure, that GitProviderMock does implement GitProvider.
// If this is not the case, regenerate this file with moq.
var _ GitProvider = &GitProviderMock{}
// GitProviderMock is a mock implementation of GitProvider.
//
// func TestSomethingThatUsesGitProvider(t *testing.T) {
//
// // make and configure a mocked GitProvider
// mockedGitProvider := &GitProviderMock{
// CheckoutMasterBranchFunc: func() error {
// panic("mock out the CheckoutMasterBranch method")
// },
// CreateAndPushBranchWithFilesFunc: func(branchName string, files []string, message string) error {
// panic("mock out the CreateAndPushBranchWithFiles method")
// },
// }
//
// // use mockedGitProvider in code that requires GitProvider
// // and then make assertions.
//
// }
type GitProviderMock struct {
// CheckoutMasterBranchFunc mocks the CheckoutMasterBranch method.
CheckoutMasterBranchFunc func() error
// CreateAndPushBranchWithFilesFunc mocks the CreateAndPushBranchWithFiles method.
CreateAndPushBranchWithFilesFunc func(branchName string, files []string, message string) error
// calls tracks calls to the methods.
calls struct {
// CheckoutMasterBranch holds details about calls to the CheckoutMasterBranch method.
CheckoutMasterBranch []struct {
}
// CreateAndPushBranchWithFiles holds details about calls to the CreateAndPushBranchWithFiles method.
CreateAndPushBranchWithFiles []struct {
// BranchName is the branchName argument value.
BranchName string
// Files is the files argument value.
Files []string
// Message is the message argument value.
Message string
}
}
lockCheckoutMasterBranch sync.RWMutex
lockCreateAndPushBranchWithFiles sync.RWMutex
}
// CheckoutMasterBranch calls CheckoutMasterBranchFunc.
func (mock *GitProviderMock) CheckoutMasterBranch() error {
callInfo := struct {
}{}
mock.lockCheckoutMasterBranch.Lock()
mock.calls.CheckoutMasterBranch = append(mock.calls.CheckoutMasterBranch, callInfo)
mock.lockCheckoutMasterBranch.Unlock()
if mock.CheckoutMasterBranchFunc == nil {
var (
errOut error
)
return errOut
}
return mock.CheckoutMasterBranchFunc()
}
// CheckoutMasterBranchCalls gets all the calls that were made to CheckoutMasterBranch.
// Check the length with:
//
// len(mockedGitProvider.CheckoutMasterBranchCalls())
func (mock *GitProviderMock) CheckoutMasterBranchCalls() []struct {
} {
var calls []struct {
}
mock.lockCheckoutMasterBranch.RLock()
calls = mock.calls.CheckoutMasterBranch
mock.lockCheckoutMasterBranch.RUnlock()
return calls
}
// CreateAndPushBranchWithFiles calls CreateAndPushBranchWithFilesFunc.
func (mock *GitProviderMock) CreateAndPushBranchWithFiles(branchName string, files []string, message string) error {
callInfo := struct {
BranchName string
Files []string
Message string
}{
BranchName: branchName,
Files: files,
Message: message,
}
mock.lockCreateAndPushBranchWithFiles.Lock()
mock.calls.CreateAndPushBranchWithFiles = append(mock.calls.CreateAndPushBranchWithFiles, callInfo)
mock.lockCreateAndPushBranchWithFiles.Unlock()
if mock.CreateAndPushBranchWithFilesFunc == nil {
var (
errOut error
)
return errOut
}
return mock.CreateAndPushBranchWithFilesFunc(branchName, files, message)
}
// CreateAndPushBranchWithFilesCalls gets all the calls that were made to CreateAndPushBranchWithFiles.
// Check the length with:
//
// len(mockedGitProvider.CreateAndPushBranchWithFilesCalls())
func (mock *GitProviderMock) CreateAndPushBranchWithFilesCalls() []struct {
BranchName string
Files []string
Message string
} {
var calls []struct {
BranchName string
Files []string
Message string
}
mock.lockCreateAndPushBranchWithFiles.RLock()
calls = mock.calls.CreateAndPushBranchWithFiles
mock.lockCreateAndPushBranchWithFiles.RUnlock()
return calls
}