github.com/ungtb10d/cli/v2@v2.0.0-20221110210412-98537dd9d6a1/internal/config/config_mock.go (about) 1 // Code generated by moq; DO NOT EDIT. 2 // github.com/matryer/moq 3 4 package config 5 6 import ( 7 "sync" 8 ) 9 10 // Ensure, that ConfigMock does implement Config. 11 // If this is not the case, regenerate this file with moq. 12 var _ Config = &ConfigMock{} 13 14 // ConfigMock is a mock implementation of Config. 15 // 16 // func TestSomethingThatUsesConfig(t *testing.T) { 17 // 18 // // make and configure a mocked Config 19 // mockedConfig := &ConfigMock{ 20 // AliasesFunc: func() *AliasConfig { 21 // panic("mock out the Aliases method") 22 // }, 23 // AuthTokenFunc: func(s string) (string, string) { 24 // panic("mock out the AuthToken method") 25 // }, 26 // DefaultHostFunc: func() (string, string) { 27 // panic("mock out the DefaultHost method") 28 // }, 29 // GetFunc: func(s1 string, s2 string) (string, error) { 30 // panic("mock out the Get method") 31 // }, 32 // GetOrDefaultFunc: func(s1 string, s2 string) (string, error) { 33 // panic("mock out the GetOrDefault method") 34 // }, 35 // HostsFunc: func() []string { 36 // panic("mock out the Hosts method") 37 // }, 38 // SetFunc: func(s1 string, s2 string, s3 string) { 39 // panic("mock out the Set method") 40 // }, 41 // UnsetHostFunc: func(s string) { 42 // panic("mock out the UnsetHost method") 43 // }, 44 // WriteFunc: func() error { 45 // panic("mock out the Write method") 46 // }, 47 // } 48 // 49 // // use mockedConfig in code that requires Config 50 // // and then make assertions. 51 // 52 // } 53 type ConfigMock struct { 54 // AliasesFunc mocks the Aliases method. 55 AliasesFunc func() *AliasConfig 56 57 // AuthTokenFunc mocks the AuthToken method. 58 AuthTokenFunc func(s string) (string, string) 59 60 // DefaultHostFunc mocks the DefaultHost method. 61 DefaultHostFunc func() (string, string) 62 63 // GetFunc mocks the Get method. 64 GetFunc func(s1 string, s2 string) (string, error) 65 66 // GetOrDefaultFunc mocks the GetOrDefault method. 67 GetOrDefaultFunc func(s1 string, s2 string) (string, error) 68 69 // HostsFunc mocks the Hosts method. 70 HostsFunc func() []string 71 72 // SetFunc mocks the Set method. 73 SetFunc func(s1 string, s2 string, s3 string) 74 75 // UnsetHostFunc mocks the UnsetHost method. 76 UnsetHostFunc func(s string) 77 78 // WriteFunc mocks the Write method. 79 WriteFunc func() error 80 81 // calls tracks calls to the methods. 82 calls struct { 83 // Aliases holds details about calls to the Aliases method. 84 Aliases []struct { 85 } 86 // AuthToken holds details about calls to the AuthToken method. 87 AuthToken []struct { 88 // S is the s argument value. 89 S string 90 } 91 // DefaultHost holds details about calls to the DefaultHost method. 92 DefaultHost []struct { 93 } 94 // Get holds details about calls to the Get method. 95 Get []struct { 96 // S1 is the s1 argument value. 97 S1 string 98 // S2 is the s2 argument value. 99 S2 string 100 } 101 // GetOrDefault holds details about calls to the GetOrDefault method. 102 GetOrDefault []struct { 103 // S1 is the s1 argument value. 104 S1 string 105 // S2 is the s2 argument value. 106 S2 string 107 } 108 // Hosts holds details about calls to the Hosts method. 109 Hosts []struct { 110 } 111 // Set holds details about calls to the Set method. 112 Set []struct { 113 // S1 is the s1 argument value. 114 S1 string 115 // S2 is the s2 argument value. 116 S2 string 117 // S3 is the s3 argument value. 118 S3 string 119 } 120 // UnsetHost holds details about calls to the UnsetHost method. 121 UnsetHost []struct { 122 // S is the s argument value. 123 S string 124 } 125 // Write holds details about calls to the Write method. 126 Write []struct { 127 } 128 } 129 lockAliases sync.RWMutex 130 lockAuthToken sync.RWMutex 131 lockDefaultHost sync.RWMutex 132 lockGet sync.RWMutex 133 lockGetOrDefault sync.RWMutex 134 lockHosts sync.RWMutex 135 lockSet sync.RWMutex 136 lockUnsetHost sync.RWMutex 137 lockWrite sync.RWMutex 138 } 139 140 // Aliases calls AliasesFunc. 141 func (mock *ConfigMock) Aliases() *AliasConfig { 142 if mock.AliasesFunc == nil { 143 panic("ConfigMock.AliasesFunc: method is nil but Config.Aliases was just called") 144 } 145 callInfo := struct { 146 }{} 147 mock.lockAliases.Lock() 148 mock.calls.Aliases = append(mock.calls.Aliases, callInfo) 149 mock.lockAliases.Unlock() 150 return mock.AliasesFunc() 151 } 152 153 // AliasesCalls gets all the calls that were made to Aliases. 154 // Check the length with: 155 // len(mockedConfig.AliasesCalls()) 156 func (mock *ConfigMock) AliasesCalls() []struct { 157 } { 158 var calls []struct { 159 } 160 mock.lockAliases.RLock() 161 calls = mock.calls.Aliases 162 mock.lockAliases.RUnlock() 163 return calls 164 } 165 166 // AuthToken calls AuthTokenFunc. 167 func (mock *ConfigMock) AuthToken(s string) (string, string) { 168 if mock.AuthTokenFunc == nil { 169 panic("ConfigMock.AuthTokenFunc: method is nil but Config.AuthToken was just called") 170 } 171 callInfo := struct { 172 S string 173 }{ 174 S: s, 175 } 176 mock.lockAuthToken.Lock() 177 mock.calls.AuthToken = append(mock.calls.AuthToken, callInfo) 178 mock.lockAuthToken.Unlock() 179 return mock.AuthTokenFunc(s) 180 } 181 182 // AuthTokenCalls gets all the calls that were made to AuthToken. 183 // Check the length with: 184 // len(mockedConfig.AuthTokenCalls()) 185 func (mock *ConfigMock) AuthTokenCalls() []struct { 186 S string 187 } { 188 var calls []struct { 189 S string 190 } 191 mock.lockAuthToken.RLock() 192 calls = mock.calls.AuthToken 193 mock.lockAuthToken.RUnlock() 194 return calls 195 } 196 197 // DefaultHost calls DefaultHostFunc. 198 func (mock *ConfigMock) DefaultHost() (string, string) { 199 if mock.DefaultHostFunc == nil { 200 panic("ConfigMock.DefaultHostFunc: method is nil but Config.DefaultHost was just called") 201 } 202 callInfo := struct { 203 }{} 204 mock.lockDefaultHost.Lock() 205 mock.calls.DefaultHost = append(mock.calls.DefaultHost, callInfo) 206 mock.lockDefaultHost.Unlock() 207 return mock.DefaultHostFunc() 208 } 209 210 // DefaultHostCalls gets all the calls that were made to DefaultHost. 211 // Check the length with: 212 // len(mockedConfig.DefaultHostCalls()) 213 func (mock *ConfigMock) DefaultHostCalls() []struct { 214 } { 215 var calls []struct { 216 } 217 mock.lockDefaultHost.RLock() 218 calls = mock.calls.DefaultHost 219 mock.lockDefaultHost.RUnlock() 220 return calls 221 } 222 223 // Get calls GetFunc. 224 func (mock *ConfigMock) Get(s1 string, s2 string) (string, error) { 225 if mock.GetFunc == nil { 226 panic("ConfigMock.GetFunc: method is nil but Config.Get was just called") 227 } 228 callInfo := struct { 229 S1 string 230 S2 string 231 }{ 232 S1: s1, 233 S2: s2, 234 } 235 mock.lockGet.Lock() 236 mock.calls.Get = append(mock.calls.Get, callInfo) 237 mock.lockGet.Unlock() 238 return mock.GetFunc(s1, s2) 239 } 240 241 // GetCalls gets all the calls that were made to Get. 242 // Check the length with: 243 // len(mockedConfig.GetCalls()) 244 func (mock *ConfigMock) GetCalls() []struct { 245 S1 string 246 S2 string 247 } { 248 var calls []struct { 249 S1 string 250 S2 string 251 } 252 mock.lockGet.RLock() 253 calls = mock.calls.Get 254 mock.lockGet.RUnlock() 255 return calls 256 } 257 258 // GetOrDefault calls GetOrDefaultFunc. 259 func (mock *ConfigMock) GetOrDefault(s1 string, s2 string) (string, error) { 260 if mock.GetOrDefaultFunc == nil { 261 panic("ConfigMock.GetOrDefaultFunc: method is nil but Config.GetOrDefault was just called") 262 } 263 callInfo := struct { 264 S1 string 265 S2 string 266 }{ 267 S1: s1, 268 S2: s2, 269 } 270 mock.lockGetOrDefault.Lock() 271 mock.calls.GetOrDefault = append(mock.calls.GetOrDefault, callInfo) 272 mock.lockGetOrDefault.Unlock() 273 return mock.GetOrDefaultFunc(s1, s2) 274 } 275 276 // GetOrDefaultCalls gets all the calls that were made to GetOrDefault. 277 // Check the length with: 278 // len(mockedConfig.GetOrDefaultCalls()) 279 func (mock *ConfigMock) GetOrDefaultCalls() []struct { 280 S1 string 281 S2 string 282 } { 283 var calls []struct { 284 S1 string 285 S2 string 286 } 287 mock.lockGetOrDefault.RLock() 288 calls = mock.calls.GetOrDefault 289 mock.lockGetOrDefault.RUnlock() 290 return calls 291 } 292 293 // Hosts calls HostsFunc. 294 func (mock *ConfigMock) Hosts() []string { 295 if mock.HostsFunc == nil { 296 panic("ConfigMock.HostsFunc: method is nil but Config.Hosts was just called") 297 } 298 callInfo := struct { 299 }{} 300 mock.lockHosts.Lock() 301 mock.calls.Hosts = append(mock.calls.Hosts, callInfo) 302 mock.lockHosts.Unlock() 303 return mock.HostsFunc() 304 } 305 306 // HostsCalls gets all the calls that were made to Hosts. 307 // Check the length with: 308 // len(mockedConfig.HostsCalls()) 309 func (mock *ConfigMock) HostsCalls() []struct { 310 } { 311 var calls []struct { 312 } 313 mock.lockHosts.RLock() 314 calls = mock.calls.Hosts 315 mock.lockHosts.RUnlock() 316 return calls 317 } 318 319 // Set calls SetFunc. 320 func (mock *ConfigMock) Set(s1 string, s2 string, s3 string) { 321 if mock.SetFunc == nil { 322 panic("ConfigMock.SetFunc: method is nil but Config.Set was just called") 323 } 324 callInfo := struct { 325 S1 string 326 S2 string 327 S3 string 328 }{ 329 S1: s1, 330 S2: s2, 331 S3: s3, 332 } 333 mock.lockSet.Lock() 334 mock.calls.Set = append(mock.calls.Set, callInfo) 335 mock.lockSet.Unlock() 336 mock.SetFunc(s1, s2, s3) 337 } 338 339 // SetCalls gets all the calls that were made to Set. 340 // Check the length with: 341 // len(mockedConfig.SetCalls()) 342 func (mock *ConfigMock) SetCalls() []struct { 343 S1 string 344 S2 string 345 S3 string 346 } { 347 var calls []struct { 348 S1 string 349 S2 string 350 S3 string 351 } 352 mock.lockSet.RLock() 353 calls = mock.calls.Set 354 mock.lockSet.RUnlock() 355 return calls 356 } 357 358 // UnsetHost calls UnsetHostFunc. 359 func (mock *ConfigMock) UnsetHost(s string) { 360 if mock.UnsetHostFunc == nil { 361 panic("ConfigMock.UnsetHostFunc: method is nil but Config.UnsetHost was just called") 362 } 363 callInfo := struct { 364 S string 365 }{ 366 S: s, 367 } 368 mock.lockUnsetHost.Lock() 369 mock.calls.UnsetHost = append(mock.calls.UnsetHost, callInfo) 370 mock.lockUnsetHost.Unlock() 371 mock.UnsetHostFunc(s) 372 } 373 374 // UnsetHostCalls gets all the calls that were made to UnsetHost. 375 // Check the length with: 376 // len(mockedConfig.UnsetHostCalls()) 377 func (mock *ConfigMock) UnsetHostCalls() []struct { 378 S string 379 } { 380 var calls []struct { 381 S string 382 } 383 mock.lockUnsetHost.RLock() 384 calls = mock.calls.UnsetHost 385 mock.lockUnsetHost.RUnlock() 386 return calls 387 } 388 389 // Write calls WriteFunc. 390 func (mock *ConfigMock) Write() error { 391 if mock.WriteFunc == nil { 392 panic("ConfigMock.WriteFunc: method is nil but Config.Write was just called") 393 } 394 callInfo := struct { 395 }{} 396 mock.lockWrite.Lock() 397 mock.calls.Write = append(mock.calls.Write, callInfo) 398 mock.lockWrite.Unlock() 399 return mock.WriteFunc() 400 } 401 402 // WriteCalls gets all the calls that were made to Write. 403 // Check the length with: 404 // len(mockedConfig.WriteCalls()) 405 func (mock *ConfigMock) WriteCalls() []struct { 406 } { 407 var calls []struct { 408 } 409 mock.lockWrite.RLock() 410 calls = mock.calls.Write 411 mock.lockWrite.RUnlock() 412 return calls 413 }