123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727 |
- // Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
- package mocks
- //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/thing.ThingImageRepository -o thing_image_repository_minimock.go -n ThingImageRepositoryMock -p mocks
- import (
- "context"
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "git.dmitriygnatenko.ru/dima/homethings/internal/models"
- "github.com/gojuno/minimock/v3"
- )
- // ThingImageRepositoryMock implements thing.ThingImageRepository
- type ThingImageRepositoryMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcDelete func(ctx context.Context, id uint64) (err error)
- inspectFuncDelete func(ctx context.Context, id uint64)
- afterDeleteCounter uint64
- beforeDeleteCounter uint64
- DeleteMock mThingImageRepositoryMockDelete
- funcGetByThingID func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
- inspectFuncGetByThingID func(ctx context.Context, id uint64)
- afterGetByThingIDCounter uint64
- beforeGetByThingIDCounter uint64
- GetByThingIDMock mThingImageRepositoryMockGetByThingID
- }
- // NewThingImageRepositoryMock returns a mock for thing.ThingImageRepository
- func NewThingImageRepositoryMock(t minimock.Tester) *ThingImageRepositoryMock {
- m := &ThingImageRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.DeleteMock = mThingImageRepositoryMockDelete{mock: m}
- m.DeleteMock.callArgs = []*ThingImageRepositoryMockDeleteParams{}
- m.GetByThingIDMock = mThingImageRepositoryMockGetByThingID{mock: m}
- m.GetByThingIDMock.callArgs = []*ThingImageRepositoryMockGetByThingIDParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mThingImageRepositoryMockDelete struct {
- optional bool
- mock *ThingImageRepositoryMock
- defaultExpectation *ThingImageRepositoryMockDeleteExpectation
- expectations []*ThingImageRepositoryMockDeleteExpectation
- callArgs []*ThingImageRepositoryMockDeleteParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingImageRepositoryMockDeleteExpectation specifies expectation struct of the ThingImageRepository.Delete
- type ThingImageRepositoryMockDeleteExpectation struct {
- mock *ThingImageRepositoryMock
- params *ThingImageRepositoryMockDeleteParams
- paramPtrs *ThingImageRepositoryMockDeleteParamPtrs
- results *ThingImageRepositoryMockDeleteResults
- Counter uint64
- }
- // ThingImageRepositoryMockDeleteParams contains parameters of the ThingImageRepository.Delete
- type ThingImageRepositoryMockDeleteParams struct {
- ctx context.Context
- id uint64
- }
- // ThingImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingImageRepository.Delete
- type ThingImageRepositoryMockDeleteParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // ThingImageRepositoryMockDeleteResults contains results of the ThingImageRepository.Delete
- type ThingImageRepositoryMockDeleteResults 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 *mThingImageRepositoryMockDelete) Optional() *mThingImageRepositoryMockDelete {
- mmDelete.optional = true
- return mmDelete
- }
- // Expect sets up expected params for ThingImageRepository.Delete
- func (mmDelete *mThingImageRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.paramPtrs != nil {
- mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by ExpectParams functions")
- }
- mmDelete.defaultExpectation.params = &ThingImageRepositoryMockDeleteParams{ctx, id}
- 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
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.Delete
- func (mmDelete *mThingImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
- return mmDelete
- }
- // ExpectIdParam2 sets up expected param id for ThingImageRepository.Delete
- func (mmDelete *mThingImageRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingImageRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &ThingImageRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.id = &id
- return mmDelete
- }
- // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Delete
- func (mmDelete *mThingImageRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockDelete {
- if mmDelete.mock.inspectFuncDelete != nil {
- mmDelete.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Delete")
- }
- mmDelete.mock.inspectFuncDelete = f
- return mmDelete
- }
- // Return sets up results that will be returned by ThingImageRepository.Delete
- func (mmDelete *mThingImageRepositoryMockDelete) Return(err error) *ThingImageRepositoryMock {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingImageRepositoryMockDeleteExpectation{mock: mmDelete.mock}
- }
- mmDelete.defaultExpectation.results = &ThingImageRepositoryMockDeleteResults{err}
- return mmDelete.mock
- }
- // Set uses given function f to mock the ThingImageRepository.Delete method
- func (mmDelete *mThingImageRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingImageRepositoryMock {
- if mmDelete.defaultExpectation != nil {
- mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Delete method")
- }
- if len(mmDelete.expectations) > 0 {
- mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.Delete method")
- }
- mmDelete.mock.funcDelete = f
- return mmDelete.mock
- }
- // When sets expectation for the ThingImageRepository.Delete which will trigger the result defined by the following
- // Then helper
- func (mmDelete *mThingImageRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingImageRepositoryMockDeleteExpectation {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingImageRepositoryMock.Delete mock is already set by Set")
- }
- expectation := &ThingImageRepositoryMockDeleteExpectation{
- mock: mmDelete.mock,
- params: &ThingImageRepositoryMockDeleteParams{ctx, id},
- }
- mmDelete.expectations = append(mmDelete.expectations, expectation)
- return expectation
- }
- // Then sets up ThingImageRepository.Delete return parameters for the expectation previously defined by the When method
- func (e *ThingImageRepositoryMockDeleteExpectation) Then(err error) *ThingImageRepositoryMock {
- e.results = &ThingImageRepositoryMockDeleteResults{err}
- return e.mock
- }
- // Times sets number of times ThingImageRepository.Delete should be invoked
- func (mmDelete *mThingImageRepositoryMockDelete) Times(n uint64) *mThingImageRepositoryMockDelete {
- if n == 0 {
- mmDelete.mock.t.Fatalf("Times of ThingImageRepositoryMock.Delete mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
- return mmDelete
- }
- func (mmDelete *mThingImageRepositoryMockDelete) 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 thing.ThingImageRepository
- func (mmDelete *ThingImageRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
- mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
- defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
- if mmDelete.inspectFuncDelete != nil {
- mmDelete.inspectFuncDelete(ctx, id)
- }
- mm_params := ThingImageRepositoryMockDeleteParams{ctx, id}
- // 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 := ThingImageRepositoryMockDeleteParams{ctx, id}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
- mmDelete.t.Errorf("ThingImageRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmDelete.t.Errorf("ThingImageRepositoryMock.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 ThingImageRepositoryMock.Delete")
- }
- return (*mm_results).err
- }
- if mmDelete.funcDelete != nil {
- return mmDelete.funcDelete(ctx, id)
- }
- mmDelete.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Delete. %v %v", ctx, id)
- return
- }
- // DeleteAfterCounter returns a count of finished ThingImageRepositoryMock.Delete invocations
- func (mmDelete *ThingImageRepositoryMock) DeleteAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
- }
- // DeleteBeforeCounter returns a count of ThingImageRepositoryMock.Delete invocations
- func (mmDelete *ThingImageRepositoryMock) DeleteBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
- }
- // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.Delete.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmDelete *mThingImageRepositoryMockDelete) Calls() []*ThingImageRepositoryMockDeleteParams {
- mmDelete.mutex.RLock()
- argCopy := make([]*ThingImageRepositoryMockDeleteParams, 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 *ThingImageRepositoryMock) 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 *ThingImageRepositoryMock) MinimockDeleteInspect() {
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.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 ThingImageRepositoryMock.Delete")
- } else {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.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 ThingImageRepositoryMock.Delete")
- }
- if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.Delete but found %d calls",
- mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
- }
- }
- type mThingImageRepositoryMockGetByThingID struct {
- optional bool
- mock *ThingImageRepositoryMock
- defaultExpectation *ThingImageRepositoryMockGetByThingIDExpectation
- expectations []*ThingImageRepositoryMockGetByThingIDExpectation
- callArgs []*ThingImageRepositoryMockGetByThingIDParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingImageRepositoryMockGetByThingIDExpectation specifies expectation struct of the ThingImageRepository.GetByThingID
- type ThingImageRepositoryMockGetByThingIDExpectation struct {
- mock *ThingImageRepositoryMock
- params *ThingImageRepositoryMockGetByThingIDParams
- paramPtrs *ThingImageRepositoryMockGetByThingIDParamPtrs
- results *ThingImageRepositoryMockGetByThingIDResults
- Counter uint64
- }
- // ThingImageRepositoryMockGetByThingIDParams contains parameters of the ThingImageRepository.GetByThingID
- type ThingImageRepositoryMockGetByThingIDParams struct {
- ctx context.Context
- id uint64
- }
- // ThingImageRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the ThingImageRepository.GetByThingID
- type ThingImageRepositoryMockGetByThingIDParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // ThingImageRepositoryMockGetByThingIDResults contains results of the ThingImageRepository.GetByThingID
- type ThingImageRepositoryMockGetByThingIDResults struct {
- ia1 []models.Image
- 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 (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Optional() *mThingImageRepositoryMockGetByThingID {
- mmGetByThingID.optional = true
- return mmGetByThingID
- }
- // Expect sets up expected params for ThingImageRepository.GetByThingID
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockGetByThingID {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
- }
- if mmGetByThingID.defaultExpectation == nil {
- mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
- }
- if mmGetByThingID.defaultExpectation.paramPtrs != nil {
- mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
- }
- mmGetByThingID.defaultExpectation.params = &ThingImageRepositoryMockGetByThingIDParams{ctx, id}
- for _, e := range mmGetByThingID.expectations {
- if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
- mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
- }
- }
- return mmGetByThingID
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.GetByThingID
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockGetByThingID {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
- }
- if mmGetByThingID.defaultExpectation == nil {
- mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
- }
- if mmGetByThingID.defaultExpectation.params != nil {
- mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Expect")
- }
- if mmGetByThingID.defaultExpectation.paramPtrs == nil {
- mmGetByThingID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByThingIDParamPtrs{}
- }
- mmGetByThingID.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetByThingID
- }
- // ExpectIdParam2 sets up expected param id for ThingImageRepository.GetByThingID
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) ExpectIdParam2(id uint64) *mThingImageRepositoryMockGetByThingID {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
- }
- if mmGetByThingID.defaultExpectation == nil {
- mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{}
- }
- if mmGetByThingID.defaultExpectation.params != nil {
- mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Expect")
- }
- if mmGetByThingID.defaultExpectation.paramPtrs == nil {
- mmGetByThingID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByThingIDParamPtrs{}
- }
- mmGetByThingID.defaultExpectation.paramPtrs.id = &id
- return mmGetByThingID
- }
- // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.GetByThingID
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockGetByThingID {
- if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.GetByThingID")
- }
- mmGetByThingID.mock.inspectFuncGetByThingID = f
- return mmGetByThingID
- }
- // Return sets up results that will be returned by ThingImageRepository.GetByThingID
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Return(ia1 []models.Image, err error) *ThingImageRepositoryMock {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
- }
- if mmGetByThingID.defaultExpectation == nil {
- mmGetByThingID.defaultExpectation = &ThingImageRepositoryMockGetByThingIDExpectation{mock: mmGetByThingID.mock}
- }
- mmGetByThingID.defaultExpectation.results = &ThingImageRepositoryMockGetByThingIDResults{ia1, err}
- return mmGetByThingID.mock
- }
- // Set uses given function f to mock the ThingImageRepository.GetByThingID method
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
- if mmGetByThingID.defaultExpectation != nil {
- mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.GetByThingID method")
- }
- if len(mmGetByThingID.expectations) > 0 {
- mmGetByThingID.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.GetByThingID method")
- }
- mmGetByThingID.mock.funcGetByThingID = f
- return mmGetByThingID.mock
- }
- // When sets expectation for the ThingImageRepository.GetByThingID which will trigger the result defined by the following
- // Then helper
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) When(ctx context.Context, id uint64) *ThingImageRepositoryMockGetByThingIDExpectation {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("ThingImageRepositoryMock.GetByThingID mock is already set by Set")
- }
- expectation := &ThingImageRepositoryMockGetByThingIDExpectation{
- mock: mmGetByThingID.mock,
- params: &ThingImageRepositoryMockGetByThingIDParams{ctx, id},
- }
- mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
- return expectation
- }
- // Then sets up ThingImageRepository.GetByThingID return parameters for the expectation previously defined by the When method
- func (e *ThingImageRepositoryMockGetByThingIDExpectation) Then(ia1 []models.Image, err error) *ThingImageRepositoryMock {
- e.results = &ThingImageRepositoryMockGetByThingIDResults{ia1, err}
- return e.mock
- }
- // Times sets number of times ThingImageRepository.GetByThingID should be invoked
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Times(n uint64) *mThingImageRepositoryMockGetByThingID {
- if n == 0 {
- mmGetByThingID.mock.t.Fatalf("Times of ThingImageRepositoryMock.GetByThingID mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetByThingID.expectedInvocations, n)
- return mmGetByThingID
- }
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) invocationsDone() bool {
- if len(mmGetByThingID.expectations) == 0 && mmGetByThingID.defaultExpectation == nil && mmGetByThingID.mock.funcGetByThingID == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetByThingID.mock.afterGetByThingIDCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetByThingID.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetByThingID implements thing.ThingImageRepository
- func (mmGetByThingID *ThingImageRepositoryMock) GetByThingID(ctx context.Context, id uint64) (ia1 []models.Image, err error) {
- mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
- defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)
- if mmGetByThingID.inspectFuncGetByThingID != nil {
- mmGetByThingID.inspectFuncGetByThingID(ctx, id)
- }
- mm_params := ThingImageRepositoryMockGetByThingIDParams{ctx, id}
- // Record call args
- mmGetByThingID.GetByThingIDMock.mutex.Lock()
- mmGetByThingID.GetByThingIDMock.callArgs = append(mmGetByThingID.GetByThingIDMock.callArgs, &mm_params)
- mmGetByThingID.GetByThingIDMock.mutex.Unlock()
- for _, e := range mmGetByThingID.GetByThingIDMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ia1, e.results.err
- }
- }
- if mmGetByThingID.GetByThingIDMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetByThingID.GetByThingIDMock.defaultExpectation.Counter, 1)
- mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
- mm_want_ptrs := mmGetByThingID.GetByThingIDMock.defaultExpectation.paramPtrs
- mm_got := ThingImageRepositoryMockGetByThingIDParams{ctx, id}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
- mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGetByThingID.t.Errorf("ThingImageRepositoryMock.GetByThingID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGetByThingID.GetByThingIDMock.defaultExpectation.results
- if mm_results == nil {
- mmGetByThingID.t.Fatal("No results are set for the ThingImageRepositoryMock.GetByThingID")
- }
- return (*mm_results).ia1, (*mm_results).err
- }
- if mmGetByThingID.funcGetByThingID != nil {
- return mmGetByThingID.funcGetByThingID(ctx, id)
- }
- mmGetByThingID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByThingID. %v %v", ctx, id)
- return
- }
- // GetByThingIDAfterCounter returns a count of finished ThingImageRepositoryMock.GetByThingID invocations
- func (mmGetByThingID *ThingImageRepositoryMock) GetByThingIDAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByThingID.afterGetByThingIDCounter)
- }
- // GetByThingIDBeforeCounter returns a count of ThingImageRepositoryMock.GetByThingID invocations
- func (mmGetByThingID *ThingImageRepositoryMock) GetByThingIDBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByThingID.beforeGetByThingIDCounter)
- }
- // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.GetByThingID.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetByThingID *mThingImageRepositoryMockGetByThingID) Calls() []*ThingImageRepositoryMockGetByThingIDParams {
- mmGetByThingID.mutex.RLock()
- argCopy := make([]*ThingImageRepositoryMockGetByThingIDParams, len(mmGetByThingID.callArgs))
- copy(argCopy, mmGetByThingID.callArgs)
- mmGetByThingID.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetByThingIDDone returns true if the count of the GetByThingID invocations corresponds
- // the number of defined expectations
- func (m *ThingImageRepositoryMock) MinimockGetByThingIDDone() bool {
- if m.GetByThingIDMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetByThingIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetByThingIDMock.invocationsDone()
- }
- // MinimockGetByThingIDInspect logs each unmet expectation
- func (m *ThingImageRepositoryMock) MinimockGetByThingIDInspect() {
- for _, e := range m.GetByThingIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByThingID with params: %#v", *e.params)
- }
- }
- afterGetByThingIDCounter := mm_atomic.LoadUint64(&m.afterGetByThingIDCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetByThingIDMock.defaultExpectation != nil && afterGetByThingIDCounter < 1 {
- if m.GetByThingIDMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingImageRepositoryMock.GetByThingID")
- } else {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByThingID with params: %#v", *m.GetByThingIDMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetByThingID != nil && afterGetByThingIDCounter < 1 {
- m.t.Error("Expected call to ThingImageRepositoryMock.GetByThingID")
- }
- if !m.GetByThingIDMock.invocationsDone() && afterGetByThingIDCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.GetByThingID but found %d calls",
- mm_atomic.LoadUint64(&m.GetByThingIDMock.expectedInvocations), afterGetByThingIDCounter)
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *ThingImageRepositoryMock) MinimockFinish() {
- m.finishOnce.Do(func() {
- if !m.minimockDone() {
- m.MinimockDeleteInspect()
- m.MinimockGetByThingIDInspect()
- }
- })
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *ThingImageRepositoryMock) 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 *ThingImageRepositoryMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockDeleteDone() &&
- m.MinimockGetByThingIDDone()
- }
|