// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT. package mocks //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/image.FileRepository -o file_repository_minimock.go -n FileRepositoryMock -p mocks import ( "mime/multipart" "sync" mm_atomic "sync/atomic" mm_time "time" "github.com/gofiber/fiber/v2" "github.com/gojuno/minimock/v3" ) // FileRepositoryMock implements image.FileRepository type FileRepositoryMock struct { t minimock.Tester finishOnce sync.Once funcDelete func(path string) (err error) inspectFuncDelete func(path string) afterDeleteCounter uint64 beforeDeleteCounter uint64 DeleteMock mFileRepositoryMockDelete funcSave func(fctx *fiber.Ctx, header *multipart.FileHeader, path string) (err error) inspectFuncSave func(fctx *fiber.Ctx, header *multipart.FileHeader, path string) afterSaveCounter uint64 beforeSaveCounter uint64 SaveMock mFileRepositoryMockSave } // NewFileRepositoryMock returns a mock for image.FileRepository func NewFileRepositoryMock(t minimock.Tester) *FileRepositoryMock { m := &FileRepositoryMock{t: t} if controller, ok := t.(minimock.MockController); ok { controller.RegisterMocker(m) } m.DeleteMock = mFileRepositoryMockDelete{mock: m} m.DeleteMock.callArgs = []*FileRepositoryMockDeleteParams{} m.SaveMock = mFileRepositoryMockSave{mock: m} m.SaveMock.callArgs = []*FileRepositoryMockSaveParams{} t.Cleanup(m.MinimockFinish) return m } type mFileRepositoryMockDelete struct { optional bool mock *FileRepositoryMock defaultExpectation *FileRepositoryMockDeleteExpectation expectations []*FileRepositoryMockDeleteExpectation callArgs []*FileRepositoryMockDeleteParams mutex sync.RWMutex expectedInvocations uint64 } // FileRepositoryMockDeleteExpectation specifies expectation struct of the FileRepository.Delete type FileRepositoryMockDeleteExpectation struct { mock *FileRepositoryMock params *FileRepositoryMockDeleteParams paramPtrs *FileRepositoryMockDeleteParamPtrs results *FileRepositoryMockDeleteResults Counter uint64 } // FileRepositoryMockDeleteParams contains parameters of the FileRepository.Delete type FileRepositoryMockDeleteParams struct { path string } // FileRepositoryMockDeleteParamPtrs contains pointers to parameters of the FileRepository.Delete type FileRepositoryMockDeleteParamPtrs struct { path *string } // FileRepositoryMockDeleteResults contains results of the FileRepository.Delete type FileRepositoryMockDeleteResults struct { err error } // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning // the test will fail minimock's automatic final call check if the mocked method was not called at least once. // Optional() makes method check to work in '0 or more' mode. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to // catch the problems when the expected method call is totally skipped during test run. func (mmDelete *mFileRepositoryMockDelete) Optional() *mFileRepositoryMockDelete { mmDelete.optional = true return mmDelete } // Expect sets up expected params for FileRepository.Delete func (mmDelete *mFileRepositoryMockDelete) Expect(path string) *mFileRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &FileRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.paramPtrs != nil { mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by ExpectParams functions") } mmDelete.defaultExpectation.params = &FileRepositoryMockDeleteParams{path} for _, e := range mmDelete.expectations { if minimock.Equal(e.params, mmDelete.defaultExpectation.params) { mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params) } } return mmDelete } // ExpectPathParam1 sets up expected param path for FileRepository.Delete func (mmDelete *mFileRepositoryMockDelete) ExpectPathParam1(path string) *mFileRepositoryMockDelete { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &FileRepositoryMockDeleteExpectation{} } if mmDelete.defaultExpectation.params != nil { mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by Expect") } if mmDelete.defaultExpectation.paramPtrs == nil { mmDelete.defaultExpectation.paramPtrs = &FileRepositoryMockDeleteParamPtrs{} } mmDelete.defaultExpectation.paramPtrs.path = &path return mmDelete } // Inspect accepts an inspector function that has same arguments as the FileRepository.Delete func (mmDelete *mFileRepositoryMockDelete) Inspect(f func(path string)) *mFileRepositoryMockDelete { if mmDelete.mock.inspectFuncDelete != nil { mmDelete.mock.t.Fatalf("Inspect function is already set for FileRepositoryMock.Delete") } mmDelete.mock.inspectFuncDelete = f return mmDelete } // Return sets up results that will be returned by FileRepository.Delete func (mmDelete *mFileRepositoryMockDelete) Return(err error) *FileRepositoryMock { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by Set") } if mmDelete.defaultExpectation == nil { mmDelete.defaultExpectation = &FileRepositoryMockDeleteExpectation{mock: mmDelete.mock} } mmDelete.defaultExpectation.results = &FileRepositoryMockDeleteResults{err} return mmDelete.mock } // Set uses given function f to mock the FileRepository.Delete method func (mmDelete *mFileRepositoryMockDelete) Set(f func(path string) (err error)) *FileRepositoryMock { if mmDelete.defaultExpectation != nil { mmDelete.mock.t.Fatalf("Default expectation is already set for the FileRepository.Delete method") } if len(mmDelete.expectations) > 0 { mmDelete.mock.t.Fatalf("Some expectations are already set for the FileRepository.Delete method") } mmDelete.mock.funcDelete = f return mmDelete.mock } // When sets expectation for the FileRepository.Delete which will trigger the result defined by the following // Then helper func (mmDelete *mFileRepositoryMockDelete) When(path string) *FileRepositoryMockDeleteExpectation { if mmDelete.mock.funcDelete != nil { mmDelete.mock.t.Fatalf("FileRepositoryMock.Delete mock is already set by Set") } expectation := &FileRepositoryMockDeleteExpectation{ mock: mmDelete.mock, params: &FileRepositoryMockDeleteParams{path}, } mmDelete.expectations = append(mmDelete.expectations, expectation) return expectation } // Then sets up FileRepository.Delete return parameters for the expectation previously defined by the When method func (e *FileRepositoryMockDeleteExpectation) Then(err error) *FileRepositoryMock { e.results = &FileRepositoryMockDeleteResults{err} return e.mock } // Times sets number of times FileRepository.Delete should be invoked func (mmDelete *mFileRepositoryMockDelete) Times(n uint64) *mFileRepositoryMockDelete { if n == 0 { mmDelete.mock.t.Fatalf("Times of FileRepositoryMock.Delete mock can not be zero") } mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n) return mmDelete } func (mmDelete *mFileRepositoryMockDelete) invocationsDone() bool { if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil { return true } totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter) expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations) return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) } // Delete implements image.FileRepository func (mmDelete *FileRepositoryMock) Delete(path string) (err error) { mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1) defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1) if mmDelete.inspectFuncDelete != nil { mmDelete.inspectFuncDelete(path) } mm_params := FileRepositoryMockDeleteParams{path} // Record call args mmDelete.DeleteMock.mutex.Lock() mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params) mmDelete.DeleteMock.mutex.Unlock() for _, e := range mmDelete.DeleteMock.expectations { if minimock.Equal(*e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.err } } if mmDelete.DeleteMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1) mm_want := mmDelete.DeleteMock.defaultExpectation.params mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs mm_got := FileRepositoryMockDeleteParams{path} if mm_want_ptrs != nil { if mm_want_ptrs.path != nil && !minimock.Equal(*mm_want_ptrs.path, mm_got.path) { mmDelete.t.Errorf("FileRepositoryMock.Delete got unexpected parameter path, want: %#v, got: %#v%s\n", *mm_want_ptrs.path, mm_got.path, minimock.Diff(*mm_want_ptrs.path, mm_got.path)) } } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmDelete.t.Errorf("FileRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmDelete.DeleteMock.defaultExpectation.results if mm_results == nil { mmDelete.t.Fatal("No results are set for the FileRepositoryMock.Delete") } return (*mm_results).err } if mmDelete.funcDelete != nil { return mmDelete.funcDelete(path) } mmDelete.t.Fatalf("Unexpected call to FileRepositoryMock.Delete. %v", path) return } // DeleteAfterCounter returns a count of finished FileRepositoryMock.Delete invocations func (mmDelete *FileRepositoryMock) DeleteAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter) } // DeleteBeforeCounter returns a count of FileRepositoryMock.Delete invocations func (mmDelete *FileRepositoryMock) DeleteBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter) } // Calls returns a list of arguments used in each call to FileRepositoryMock.Delete. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmDelete *mFileRepositoryMockDelete) Calls() []*FileRepositoryMockDeleteParams { mmDelete.mutex.RLock() argCopy := make([]*FileRepositoryMockDeleteParams, len(mmDelete.callArgs)) copy(argCopy, mmDelete.callArgs) mmDelete.mutex.RUnlock() return argCopy } // MinimockDeleteDone returns true if the count of the Delete invocations corresponds // the number of defined expectations func (m *FileRepositoryMock) MinimockDeleteDone() bool { if m.DeleteMock.optional { // Optional methods provide '0 or more' call count restriction. return true } for _, e := range m.DeleteMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } return m.DeleteMock.invocationsDone() } // MinimockDeleteInspect logs each unmet expectation func (m *FileRepositoryMock) MinimockDeleteInspect() { for _, e := range m.DeleteMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to FileRepositoryMock.Delete with params: %#v", *e.params) } } afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter) // if default expectation was set then invocations count should be greater than zero if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 { if m.DeleteMock.defaultExpectation.params == nil { m.t.Error("Expected call to FileRepositoryMock.Delete") } else { m.t.Errorf("Expected call to FileRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcDelete != nil && afterDeleteCounter < 1 { m.t.Error("Expected call to FileRepositoryMock.Delete") } if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 { m.t.Errorf("Expected %d calls to FileRepositoryMock.Delete but found %d calls", mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter) } } type mFileRepositoryMockSave struct { optional bool mock *FileRepositoryMock defaultExpectation *FileRepositoryMockSaveExpectation expectations []*FileRepositoryMockSaveExpectation callArgs []*FileRepositoryMockSaveParams mutex sync.RWMutex expectedInvocations uint64 } // FileRepositoryMockSaveExpectation specifies expectation struct of the FileRepository.Save type FileRepositoryMockSaveExpectation struct { mock *FileRepositoryMock params *FileRepositoryMockSaveParams paramPtrs *FileRepositoryMockSaveParamPtrs results *FileRepositoryMockSaveResults Counter uint64 } // FileRepositoryMockSaveParams contains parameters of the FileRepository.Save type FileRepositoryMockSaveParams struct { fctx *fiber.Ctx header *multipart.FileHeader path string } // FileRepositoryMockSaveParamPtrs contains pointers to parameters of the FileRepository.Save type FileRepositoryMockSaveParamPtrs struct { fctx **fiber.Ctx header **multipart.FileHeader path *string } // FileRepositoryMockSaveResults contains results of the FileRepository.Save type FileRepositoryMockSaveResults struct { err error } // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning // the test will fail minimock's automatic final call check if the mocked method was not called at least once. // Optional() makes method check to work in '0 or more' mode. // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to // catch the problems when the expected method call is totally skipped during test run. func (mmSave *mFileRepositoryMockSave) Optional() *mFileRepositoryMockSave { mmSave.optional = true return mmSave } // Expect sets up expected params for FileRepository.Save func (mmSave *mFileRepositoryMockSave) Expect(fctx *fiber.Ctx, header *multipart.FileHeader, path string) *mFileRepositoryMockSave { if mmSave.mock.funcSave != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Set") } if mmSave.defaultExpectation == nil { mmSave.defaultExpectation = &FileRepositoryMockSaveExpectation{} } if mmSave.defaultExpectation.paramPtrs != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by ExpectParams functions") } mmSave.defaultExpectation.params = &FileRepositoryMockSaveParams{fctx, header, path} for _, e := range mmSave.expectations { if minimock.Equal(e.params, mmSave.defaultExpectation.params) { mmSave.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSave.defaultExpectation.params) } } return mmSave } // ExpectFctxParam1 sets up expected param fctx for FileRepository.Save func (mmSave *mFileRepositoryMockSave) ExpectFctxParam1(fctx *fiber.Ctx) *mFileRepositoryMockSave { if mmSave.mock.funcSave != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Set") } if mmSave.defaultExpectation == nil { mmSave.defaultExpectation = &FileRepositoryMockSaveExpectation{} } if mmSave.defaultExpectation.params != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Expect") } if mmSave.defaultExpectation.paramPtrs == nil { mmSave.defaultExpectation.paramPtrs = &FileRepositoryMockSaveParamPtrs{} } mmSave.defaultExpectation.paramPtrs.fctx = &fctx return mmSave } // ExpectHeaderParam2 sets up expected param header for FileRepository.Save func (mmSave *mFileRepositoryMockSave) ExpectHeaderParam2(header *multipart.FileHeader) *mFileRepositoryMockSave { if mmSave.mock.funcSave != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Set") } if mmSave.defaultExpectation == nil { mmSave.defaultExpectation = &FileRepositoryMockSaveExpectation{} } if mmSave.defaultExpectation.params != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Expect") } if mmSave.defaultExpectation.paramPtrs == nil { mmSave.defaultExpectation.paramPtrs = &FileRepositoryMockSaveParamPtrs{} } mmSave.defaultExpectation.paramPtrs.header = &header return mmSave } // ExpectPathParam3 sets up expected param path for FileRepository.Save func (mmSave *mFileRepositoryMockSave) ExpectPathParam3(path string) *mFileRepositoryMockSave { if mmSave.mock.funcSave != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Set") } if mmSave.defaultExpectation == nil { mmSave.defaultExpectation = &FileRepositoryMockSaveExpectation{} } if mmSave.defaultExpectation.params != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Expect") } if mmSave.defaultExpectation.paramPtrs == nil { mmSave.defaultExpectation.paramPtrs = &FileRepositoryMockSaveParamPtrs{} } mmSave.defaultExpectation.paramPtrs.path = &path return mmSave } // Inspect accepts an inspector function that has same arguments as the FileRepository.Save func (mmSave *mFileRepositoryMockSave) Inspect(f func(fctx *fiber.Ctx, header *multipart.FileHeader, path string)) *mFileRepositoryMockSave { if mmSave.mock.inspectFuncSave != nil { mmSave.mock.t.Fatalf("Inspect function is already set for FileRepositoryMock.Save") } mmSave.mock.inspectFuncSave = f return mmSave } // Return sets up results that will be returned by FileRepository.Save func (mmSave *mFileRepositoryMockSave) Return(err error) *FileRepositoryMock { if mmSave.mock.funcSave != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Set") } if mmSave.defaultExpectation == nil { mmSave.defaultExpectation = &FileRepositoryMockSaveExpectation{mock: mmSave.mock} } mmSave.defaultExpectation.results = &FileRepositoryMockSaveResults{err} return mmSave.mock } // Set uses given function f to mock the FileRepository.Save method func (mmSave *mFileRepositoryMockSave) Set(f func(fctx *fiber.Ctx, header *multipart.FileHeader, path string) (err error)) *FileRepositoryMock { if mmSave.defaultExpectation != nil { mmSave.mock.t.Fatalf("Default expectation is already set for the FileRepository.Save method") } if len(mmSave.expectations) > 0 { mmSave.mock.t.Fatalf("Some expectations are already set for the FileRepository.Save method") } mmSave.mock.funcSave = f return mmSave.mock } // When sets expectation for the FileRepository.Save which will trigger the result defined by the following // Then helper func (mmSave *mFileRepositoryMockSave) When(fctx *fiber.Ctx, header *multipart.FileHeader, path string) *FileRepositoryMockSaveExpectation { if mmSave.mock.funcSave != nil { mmSave.mock.t.Fatalf("FileRepositoryMock.Save mock is already set by Set") } expectation := &FileRepositoryMockSaveExpectation{ mock: mmSave.mock, params: &FileRepositoryMockSaveParams{fctx, header, path}, } mmSave.expectations = append(mmSave.expectations, expectation) return expectation } // Then sets up FileRepository.Save return parameters for the expectation previously defined by the When method func (e *FileRepositoryMockSaveExpectation) Then(err error) *FileRepositoryMock { e.results = &FileRepositoryMockSaveResults{err} return e.mock } // Times sets number of times FileRepository.Save should be invoked func (mmSave *mFileRepositoryMockSave) Times(n uint64) *mFileRepositoryMockSave { if n == 0 { mmSave.mock.t.Fatalf("Times of FileRepositoryMock.Save mock can not be zero") } mm_atomic.StoreUint64(&mmSave.expectedInvocations, n) return mmSave } func (mmSave *mFileRepositoryMockSave) invocationsDone() bool { if len(mmSave.expectations) == 0 && mmSave.defaultExpectation == nil && mmSave.mock.funcSave == nil { return true } totalInvocations := mm_atomic.LoadUint64(&mmSave.mock.afterSaveCounter) expectedInvocations := mm_atomic.LoadUint64(&mmSave.expectedInvocations) return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) } // Save implements image.FileRepository func (mmSave *FileRepositoryMock) Save(fctx *fiber.Ctx, header *multipart.FileHeader, path string) (err error) { mm_atomic.AddUint64(&mmSave.beforeSaveCounter, 1) defer mm_atomic.AddUint64(&mmSave.afterSaveCounter, 1) if mmSave.inspectFuncSave != nil { mmSave.inspectFuncSave(fctx, header, path) } mm_params := FileRepositoryMockSaveParams{fctx, header, path} // Record call args mmSave.SaveMock.mutex.Lock() mmSave.SaveMock.callArgs = append(mmSave.SaveMock.callArgs, &mm_params) mmSave.SaveMock.mutex.Unlock() for _, e := range mmSave.SaveMock.expectations { if minimock.Equal(*e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.err } } if mmSave.SaveMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmSave.SaveMock.defaultExpectation.Counter, 1) mm_want := mmSave.SaveMock.defaultExpectation.params mm_want_ptrs := mmSave.SaveMock.defaultExpectation.paramPtrs mm_got := FileRepositoryMockSaveParams{fctx, header, path} if mm_want_ptrs != nil { if mm_want_ptrs.fctx != nil && !minimock.Equal(*mm_want_ptrs.fctx, mm_got.fctx) { mmSave.t.Errorf("FileRepositoryMock.Save got unexpected parameter fctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.fctx, mm_got.fctx, minimock.Diff(*mm_want_ptrs.fctx, mm_got.fctx)) } if mm_want_ptrs.header != nil && !minimock.Equal(*mm_want_ptrs.header, mm_got.header) { mmSave.t.Errorf("FileRepositoryMock.Save got unexpected parameter header, want: %#v, got: %#v%s\n", *mm_want_ptrs.header, mm_got.header, minimock.Diff(*mm_want_ptrs.header, mm_got.header)) } if mm_want_ptrs.path != nil && !minimock.Equal(*mm_want_ptrs.path, mm_got.path) { mmSave.t.Errorf("FileRepositoryMock.Save got unexpected parameter path, want: %#v, got: %#v%s\n", *mm_want_ptrs.path, mm_got.path, minimock.Diff(*mm_want_ptrs.path, mm_got.path)) } } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmSave.t.Errorf("FileRepositoryMock.Save got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } mm_results := mmSave.SaveMock.defaultExpectation.results if mm_results == nil { mmSave.t.Fatal("No results are set for the FileRepositoryMock.Save") } return (*mm_results).err } if mmSave.funcSave != nil { return mmSave.funcSave(fctx, header, path) } mmSave.t.Fatalf("Unexpected call to FileRepositoryMock.Save. %v %v %v", fctx, header, path) return } // SaveAfterCounter returns a count of finished FileRepositoryMock.Save invocations func (mmSave *FileRepositoryMock) SaveAfterCounter() uint64 { return mm_atomic.LoadUint64(&mmSave.afterSaveCounter) } // SaveBeforeCounter returns a count of FileRepositoryMock.Save invocations func (mmSave *FileRepositoryMock) SaveBeforeCounter() uint64 { return mm_atomic.LoadUint64(&mmSave.beforeSaveCounter) } // Calls returns a list of arguments used in each call to FileRepositoryMock.Save. // The list is in the same order as the calls were made (i.e. recent calls have a higher index) func (mmSave *mFileRepositoryMockSave) Calls() []*FileRepositoryMockSaveParams { mmSave.mutex.RLock() argCopy := make([]*FileRepositoryMockSaveParams, len(mmSave.callArgs)) copy(argCopy, mmSave.callArgs) mmSave.mutex.RUnlock() return argCopy } // MinimockSaveDone returns true if the count of the Save invocations corresponds // the number of defined expectations func (m *FileRepositoryMock) MinimockSaveDone() bool { if m.SaveMock.optional { // Optional methods provide '0 or more' call count restriction. return true } for _, e := range m.SaveMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { return false } } return m.SaveMock.invocationsDone() } // MinimockSaveInspect logs each unmet expectation func (m *FileRepositoryMock) MinimockSaveInspect() { for _, e := range m.SaveMock.expectations { if mm_atomic.LoadUint64(&e.Counter) < 1 { m.t.Errorf("Expected call to FileRepositoryMock.Save with params: %#v", *e.params) } } afterSaveCounter := mm_atomic.LoadUint64(&m.afterSaveCounter) // if default expectation was set then invocations count should be greater than zero if m.SaveMock.defaultExpectation != nil && afterSaveCounter < 1 { if m.SaveMock.defaultExpectation.params == nil { m.t.Error("Expected call to FileRepositoryMock.Save") } else { m.t.Errorf("Expected call to FileRepositoryMock.Save with params: %#v", *m.SaveMock.defaultExpectation.params) } } // if func was set then invocations count should be greater than zero if m.funcSave != nil && afterSaveCounter < 1 { m.t.Error("Expected call to FileRepositoryMock.Save") } if !m.SaveMock.invocationsDone() && afterSaveCounter > 0 { m.t.Errorf("Expected %d calls to FileRepositoryMock.Save but found %d calls", mm_atomic.LoadUint64(&m.SaveMock.expectedInvocations), afterSaveCounter) } } // MinimockFinish checks that all mocked methods have been called the expected number of times func (m *FileRepositoryMock) MinimockFinish() { m.finishOnce.Do(func() { if !m.minimockDone() { m.MinimockDeleteInspect() m.MinimockSaveInspect() } }) } // MinimockWait waits for all mocked methods to be called the expected number of times func (m *FileRepositoryMock) MinimockWait(timeout mm_time.Duration) { timeoutCh := mm_time.After(timeout) for { if m.minimockDone() { return } select { case <-timeoutCh: m.MinimockFinish() return case <-mm_time.After(10 * mm_time.Millisecond): } } } func (m *FileRepositoryMock) minimockDone() bool { done := true return done && m.MinimockDeleteDone() && m.MinimockSaveDone() }