-
Notifications
You must be signed in to change notification settings - Fork 41
/
credentials_moq.go
144 lines (134 loc) · 4.81 KB
/
credentials_moq.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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package gcp
import (
"context"
v1 "github.com/openshift/cloud-credential-operator/pkg/apis/cloudcredential/v1"
"sync"
)
// Ensure, that CredentialManagerMock does implement CredentialManager.
// If this is not the case, regenerate this file with moq.
var _ CredentialManager = &CredentialManagerMock{}
// CredentialManagerMock is a mock implementation of CredentialManager.
//
// func TestSomethingThatUsesCredentialManager(t *testing.T) {
//
// // make and configure a mocked CredentialManager
// mockedCredentialManager := &CredentialManagerMock{
// ReconcileCredentialsFunc: func(ctx context.Context, name string, ns string, roles []string) (*v1.CredentialsRequest, *Credentials, error) {
// panic("mock out the ReconcileCredentials method")
// },
// ReconcileProviderCredentialsFunc: func(ctx context.Context, ns string) (*Credentials, error) {
// panic("mock out the ReconcileProviderCredentials method")
// },
// }
//
// // use mockedCredentialManager in code that requires CredentialManager
// // and then make assertions.
//
// }
type CredentialManagerMock struct {
// ReconcileCredentialsFunc mocks the ReconcileCredentials method.
ReconcileCredentialsFunc func(ctx context.Context, name string, ns string, roles []string) (*v1.CredentialsRequest, *Credentials, error)
// ReconcileProviderCredentialsFunc mocks the ReconcileProviderCredentials method.
ReconcileProviderCredentialsFunc func(ctx context.Context, ns string) (*Credentials, error)
// calls tracks calls to the methods.
calls struct {
// ReconcileCredentials holds details about calls to the ReconcileCredentials method.
ReconcileCredentials []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// Name is the name argument value.
Name string
// Ns is the ns argument value.
Ns string
// Roles is the roles argument value.
Roles []string
}
// ReconcileProviderCredentials holds details about calls to the ReconcileProviderCredentials method.
ReconcileProviderCredentials []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// Ns is the ns argument value.
Ns string
}
}
lockReconcileCredentials sync.RWMutex
lockReconcileProviderCredentials sync.RWMutex
}
// ReconcileCredentials calls ReconcileCredentialsFunc.
func (mock *CredentialManagerMock) ReconcileCredentials(ctx context.Context, name string, ns string, roles []string) (*v1.CredentialsRequest, *Credentials, error) {
if mock.ReconcileCredentialsFunc == nil {
panic("CredentialManagerMock.ReconcileCredentialsFunc: method is nil but CredentialManager.ReconcileCredentials was just called")
}
callInfo := struct {
Ctx context.Context
Name string
Ns string
Roles []string
}{
Ctx: ctx,
Name: name,
Ns: ns,
Roles: roles,
}
mock.lockReconcileCredentials.Lock()
mock.calls.ReconcileCredentials = append(mock.calls.ReconcileCredentials, callInfo)
mock.lockReconcileCredentials.Unlock()
return mock.ReconcileCredentialsFunc(ctx, name, ns, roles)
}
// ReconcileCredentialsCalls gets all the calls that were made to ReconcileCredentials.
// Check the length with:
//
// len(mockedCredentialManager.ReconcileCredentialsCalls())
func (mock *CredentialManagerMock) ReconcileCredentialsCalls() []struct {
Ctx context.Context
Name string
Ns string
Roles []string
} {
var calls []struct {
Ctx context.Context
Name string
Ns string
Roles []string
}
mock.lockReconcileCredentials.RLock()
calls = mock.calls.ReconcileCredentials
mock.lockReconcileCredentials.RUnlock()
return calls
}
// ReconcileProviderCredentials calls ReconcileProviderCredentialsFunc.
func (mock *CredentialManagerMock) ReconcileProviderCredentials(ctx context.Context, ns string) (*Credentials, error) {
if mock.ReconcileProviderCredentialsFunc == nil {
panic("CredentialManagerMock.ReconcileProviderCredentialsFunc: method is nil but CredentialManager.ReconcileProviderCredentials was just called")
}
callInfo := struct {
Ctx context.Context
Ns string
}{
Ctx: ctx,
Ns: ns,
}
mock.lockReconcileProviderCredentials.Lock()
mock.calls.ReconcileProviderCredentials = append(mock.calls.ReconcileProviderCredentials, callInfo)
mock.lockReconcileProviderCredentials.Unlock()
return mock.ReconcileProviderCredentialsFunc(ctx, ns)
}
// ReconcileProviderCredentialsCalls gets all the calls that were made to ReconcileProviderCredentials.
// Check the length with:
//
// len(mockedCredentialManager.ReconcileProviderCredentialsCalls())
func (mock *CredentialManagerMock) ReconcileProviderCredentialsCalls() []struct {
Ctx context.Context
Ns string
} {
var calls []struct {
Ctx context.Context
Ns string
}
mock.lockReconcileProviderCredentials.RLock()
calls = mock.calls.ReconcileProviderCredentials
mock.lockReconcileProviderCredentials.RUnlock()
return calls
}