github.com/andrewhsu/cli/v2@v2.0.1-0.20210910131313-d4b4061f5b89/pkg/extensions/manager_mock.go (about) 1 // Code generated by moq; DO NOT EDIT. 2 // github.com/matryer/moq 3 4 package extensions 5 6 import ( 7 "io" 8 "sync" 9 ) 10 11 // Ensure, that ExtensionManagerMock does implement ExtensionManager. 12 // If this is not the case, regenerate this file with moq. 13 var _ ExtensionManager = &ExtensionManagerMock{} 14 15 // ExtensionManagerMock is a mock implementation of ExtensionManager. 16 // 17 // func TestSomethingThatUsesExtensionManager(t *testing.T) { 18 // 19 // // make and configure a mocked ExtensionManager 20 // mockedExtensionManager := &ExtensionManagerMock{ 21 // CreateFunc: func(name string) error { 22 // panic("mock out the Create method") 23 // }, 24 // DispatchFunc: func(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) (bool, error) { 25 // panic("mock out the Dispatch method") 26 // }, 27 // InstallFunc: func(url string, stdout io.Writer, stderr io.Writer) error { 28 // panic("mock out the Install method") 29 // }, 30 // InstallLocalFunc: func(dir string) error { 31 // panic("mock out the InstallLocal method") 32 // }, 33 // ListFunc: func(includeMetadata bool) []Extension { 34 // panic("mock out the List method") 35 // }, 36 // RemoveFunc: func(name string) error { 37 // panic("mock out the Remove method") 38 // }, 39 // UpgradeFunc: func(name string, force bool, stdout io.Writer, stderr io.Writer) error { 40 // panic("mock out the Upgrade method") 41 // }, 42 // } 43 // 44 // // use mockedExtensionManager in code that requires ExtensionManager 45 // // and then make assertions. 46 // 47 // } 48 type ExtensionManagerMock struct { 49 // CreateFunc mocks the Create method. 50 CreateFunc func(name string) error 51 52 // DispatchFunc mocks the Dispatch method. 53 DispatchFunc func(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) (bool, error) 54 55 // InstallFunc mocks the Install method. 56 InstallFunc func(url string, stdout io.Writer, stderr io.Writer) error 57 58 // InstallLocalFunc mocks the InstallLocal method. 59 InstallLocalFunc func(dir string) error 60 61 // ListFunc mocks the List method. 62 ListFunc func(includeMetadata bool) []Extension 63 64 // RemoveFunc mocks the Remove method. 65 RemoveFunc func(name string) error 66 67 // UpgradeFunc mocks the Upgrade method. 68 UpgradeFunc func(name string, force bool, stdout io.Writer, stderr io.Writer) error 69 70 // calls tracks calls to the methods. 71 calls struct { 72 // Create holds details about calls to the Create method. 73 Create []struct { 74 // Name is the name argument value. 75 Name string 76 } 77 // Dispatch holds details about calls to the Dispatch method. 78 Dispatch []struct { 79 // Args is the args argument value. 80 Args []string 81 // Stdin is the stdin argument value. 82 Stdin io.Reader 83 // Stdout is the stdout argument value. 84 Stdout io.Writer 85 // Stderr is the stderr argument value. 86 Stderr io.Writer 87 } 88 // Install holds details about calls to the Install method. 89 Install []struct { 90 // URL is the url argument value. 91 URL string 92 // Stdout is the stdout argument value. 93 Stdout io.Writer 94 // Stderr is the stderr argument value. 95 Stderr io.Writer 96 } 97 // InstallLocal holds details about calls to the InstallLocal method. 98 InstallLocal []struct { 99 // Dir is the dir argument value. 100 Dir string 101 } 102 // List holds details about calls to the List method. 103 List []struct { 104 // IncludeMetadata is the includeMetadata argument value. 105 IncludeMetadata bool 106 } 107 // Remove holds details about calls to the Remove method. 108 Remove []struct { 109 // Name is the name argument value. 110 Name string 111 } 112 // Upgrade holds details about calls to the Upgrade method. 113 Upgrade []struct { 114 // Name is the name argument value. 115 Name string 116 // Force is the force argument value. 117 Force bool 118 // Stdout is the stdout argument value. 119 Stdout io.Writer 120 // Stderr is the stderr argument value. 121 Stderr io.Writer 122 } 123 } 124 lockCreate sync.RWMutex 125 lockDispatch sync.RWMutex 126 lockInstall sync.RWMutex 127 lockInstallLocal sync.RWMutex 128 lockList sync.RWMutex 129 lockRemove sync.RWMutex 130 lockUpgrade sync.RWMutex 131 } 132 133 // Create calls CreateFunc. 134 func (mock *ExtensionManagerMock) Create(name string) error { 135 if mock.CreateFunc == nil { 136 panic("ExtensionManagerMock.CreateFunc: method is nil but ExtensionManager.Create was just called") 137 } 138 callInfo := struct { 139 Name string 140 }{ 141 Name: name, 142 } 143 mock.lockCreate.Lock() 144 mock.calls.Create = append(mock.calls.Create, callInfo) 145 mock.lockCreate.Unlock() 146 return mock.CreateFunc(name) 147 } 148 149 // CreateCalls gets all the calls that were made to Create. 150 // Check the length with: 151 // len(mockedExtensionManager.CreateCalls()) 152 func (mock *ExtensionManagerMock) CreateCalls() []struct { 153 Name string 154 } { 155 var calls []struct { 156 Name string 157 } 158 mock.lockCreate.RLock() 159 calls = mock.calls.Create 160 mock.lockCreate.RUnlock() 161 return calls 162 } 163 164 // Dispatch calls DispatchFunc. 165 func (mock *ExtensionManagerMock) Dispatch(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) (bool, error) { 166 if mock.DispatchFunc == nil { 167 panic("ExtensionManagerMock.DispatchFunc: method is nil but ExtensionManager.Dispatch was just called") 168 } 169 callInfo := struct { 170 Args []string 171 Stdin io.Reader 172 Stdout io.Writer 173 Stderr io.Writer 174 }{ 175 Args: args, 176 Stdin: stdin, 177 Stdout: stdout, 178 Stderr: stderr, 179 } 180 mock.lockDispatch.Lock() 181 mock.calls.Dispatch = append(mock.calls.Dispatch, callInfo) 182 mock.lockDispatch.Unlock() 183 return mock.DispatchFunc(args, stdin, stdout, stderr) 184 } 185 186 // DispatchCalls gets all the calls that were made to Dispatch. 187 // Check the length with: 188 // len(mockedExtensionManager.DispatchCalls()) 189 func (mock *ExtensionManagerMock) DispatchCalls() []struct { 190 Args []string 191 Stdin io.Reader 192 Stdout io.Writer 193 Stderr io.Writer 194 } { 195 var calls []struct { 196 Args []string 197 Stdin io.Reader 198 Stdout io.Writer 199 Stderr io.Writer 200 } 201 mock.lockDispatch.RLock() 202 calls = mock.calls.Dispatch 203 mock.lockDispatch.RUnlock() 204 return calls 205 } 206 207 // Install calls InstallFunc. 208 func (mock *ExtensionManagerMock) Install(url string, stdout io.Writer, stderr io.Writer) error { 209 if mock.InstallFunc == nil { 210 panic("ExtensionManagerMock.InstallFunc: method is nil but ExtensionManager.Install was just called") 211 } 212 callInfo := struct { 213 URL string 214 Stdout io.Writer 215 Stderr io.Writer 216 }{ 217 URL: url, 218 Stdout: stdout, 219 Stderr: stderr, 220 } 221 mock.lockInstall.Lock() 222 mock.calls.Install = append(mock.calls.Install, callInfo) 223 mock.lockInstall.Unlock() 224 return mock.InstallFunc(url, stdout, stderr) 225 } 226 227 // InstallCalls gets all the calls that were made to Install. 228 // Check the length with: 229 // len(mockedExtensionManager.InstallCalls()) 230 func (mock *ExtensionManagerMock) InstallCalls() []struct { 231 URL string 232 Stdout io.Writer 233 Stderr io.Writer 234 } { 235 var calls []struct { 236 URL string 237 Stdout io.Writer 238 Stderr io.Writer 239 } 240 mock.lockInstall.RLock() 241 calls = mock.calls.Install 242 mock.lockInstall.RUnlock() 243 return calls 244 } 245 246 // InstallLocal calls InstallLocalFunc. 247 func (mock *ExtensionManagerMock) InstallLocal(dir string) error { 248 if mock.InstallLocalFunc == nil { 249 panic("ExtensionManagerMock.InstallLocalFunc: method is nil but ExtensionManager.InstallLocal was just called") 250 } 251 callInfo := struct { 252 Dir string 253 }{ 254 Dir: dir, 255 } 256 mock.lockInstallLocal.Lock() 257 mock.calls.InstallLocal = append(mock.calls.InstallLocal, callInfo) 258 mock.lockInstallLocal.Unlock() 259 return mock.InstallLocalFunc(dir) 260 } 261 262 // InstallLocalCalls gets all the calls that were made to InstallLocal. 263 // Check the length with: 264 // len(mockedExtensionManager.InstallLocalCalls()) 265 func (mock *ExtensionManagerMock) InstallLocalCalls() []struct { 266 Dir string 267 } { 268 var calls []struct { 269 Dir string 270 } 271 mock.lockInstallLocal.RLock() 272 calls = mock.calls.InstallLocal 273 mock.lockInstallLocal.RUnlock() 274 return calls 275 } 276 277 // List calls ListFunc. 278 func (mock *ExtensionManagerMock) List(includeMetadata bool) []Extension { 279 if mock.ListFunc == nil { 280 panic("ExtensionManagerMock.ListFunc: method is nil but ExtensionManager.List was just called") 281 } 282 callInfo := struct { 283 IncludeMetadata bool 284 }{ 285 IncludeMetadata: includeMetadata, 286 } 287 mock.lockList.Lock() 288 mock.calls.List = append(mock.calls.List, callInfo) 289 mock.lockList.Unlock() 290 return mock.ListFunc(includeMetadata) 291 } 292 293 // ListCalls gets all the calls that were made to List. 294 // Check the length with: 295 // len(mockedExtensionManager.ListCalls()) 296 func (mock *ExtensionManagerMock) ListCalls() []struct { 297 IncludeMetadata bool 298 } { 299 var calls []struct { 300 IncludeMetadata bool 301 } 302 mock.lockList.RLock() 303 calls = mock.calls.List 304 mock.lockList.RUnlock() 305 return calls 306 } 307 308 // Remove calls RemoveFunc. 309 func (mock *ExtensionManagerMock) Remove(name string) error { 310 if mock.RemoveFunc == nil { 311 panic("ExtensionManagerMock.RemoveFunc: method is nil but ExtensionManager.Remove was just called") 312 } 313 callInfo := struct { 314 Name string 315 }{ 316 Name: name, 317 } 318 mock.lockRemove.Lock() 319 mock.calls.Remove = append(mock.calls.Remove, callInfo) 320 mock.lockRemove.Unlock() 321 return mock.RemoveFunc(name) 322 } 323 324 // RemoveCalls gets all the calls that were made to Remove. 325 // Check the length with: 326 // len(mockedExtensionManager.RemoveCalls()) 327 func (mock *ExtensionManagerMock) RemoveCalls() []struct { 328 Name string 329 } { 330 var calls []struct { 331 Name string 332 } 333 mock.lockRemove.RLock() 334 calls = mock.calls.Remove 335 mock.lockRemove.RUnlock() 336 return calls 337 } 338 339 // Upgrade calls UpgradeFunc. 340 func (mock *ExtensionManagerMock) Upgrade(name string, force bool, stdout io.Writer, stderr io.Writer) error { 341 if mock.UpgradeFunc == nil { 342 panic("ExtensionManagerMock.UpgradeFunc: method is nil but ExtensionManager.Upgrade was just called") 343 } 344 callInfo := struct { 345 Name string 346 Force bool 347 Stdout io.Writer 348 Stderr io.Writer 349 }{ 350 Name: name, 351 Force: force, 352 Stdout: stdout, 353 Stderr: stderr, 354 } 355 mock.lockUpgrade.Lock() 356 mock.calls.Upgrade = append(mock.calls.Upgrade, callInfo) 357 mock.lockUpgrade.Unlock() 358 return mock.UpgradeFunc(name, force, stdout, stderr) 359 } 360 361 // UpgradeCalls gets all the calls that were made to Upgrade. 362 // Check the length with: 363 // len(mockedExtensionManager.UpgradeCalls()) 364 func (mock *ExtensionManagerMock) UpgradeCalls() []struct { 365 Name string 366 Force bool 367 Stdout io.Writer 368 Stderr io.Writer 369 } { 370 var calls []struct { 371 Name string 372 Force bool 373 Stdout io.Writer 374 Stderr io.Writer 375 } 376 mock.lockUpgrade.RLock() 377 calls = mock.calls.Upgrade 378 mock.lockUpgrade.RUnlock() 379 return calls 380 }