123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725 |
- // 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/image.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 image.ThingImageRepository
- type ThingImageRepositoryMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcAdd func(ctx context.Context, req models.AddThingImageRequest) (err error)
- inspectFuncAdd func(ctx context.Context, req models.AddThingImageRequest)
- afterAddCounter uint64
- beforeAddCounter uint64
- AddMock mThingImageRepositoryMockAdd
- funcDelete func(ctx context.Context, id uint64) (err error)
- inspectFuncDelete func(ctx context.Context, id uint64)
- afterDeleteCounter uint64
- beforeDeleteCounter uint64
- DeleteMock mThingImageRepositoryMockDelete
- funcGet func(ctx context.Context, id uint64) (ip1 *models.Image, err error)
- inspectFuncGet func(ctx context.Context, id uint64)
- afterGetCounter uint64
- beforeGetCounter uint64
- GetMock mThingImageRepositoryMockGet
- funcGetByPlaceID func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
- inspectFuncGetByPlaceID func(ctx context.Context, id uint64)
- afterGetByPlaceIDCounter uint64
- beforeGetByPlaceIDCounter uint64
- GetByPlaceIDMock mThingImageRepositoryMockGetByPlaceID
- 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 image.ThingImageRepository
- func NewThingImageRepositoryMock(t minimock.Tester) *ThingImageRepositoryMock {
- m := &ThingImageRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.AddMock = mThingImageRepositoryMockAdd{mock: m}
- m.AddMock.callArgs = []*ThingImageRepositoryMockAddParams{}
- m.DeleteMock = mThingImageRepositoryMockDelete{mock: m}
- m.DeleteMock.callArgs = []*ThingImageRepositoryMockDeleteParams{}
- m.GetMock = mThingImageRepositoryMockGet{mock: m}
- m.GetMock.callArgs = []*ThingImageRepositoryMockGetParams{}
- m.GetByPlaceIDMock = mThingImageRepositoryMockGetByPlaceID{mock: m}
- m.GetByPlaceIDMock.callArgs = []*ThingImageRepositoryMockGetByPlaceIDParams{}
- m.GetByThingIDMock = mThingImageRepositoryMockGetByThingID{mock: m}
- m.GetByThingIDMock.callArgs = []*ThingImageRepositoryMockGetByThingIDParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mThingImageRepositoryMockAdd struct {
- optional bool
- mock *ThingImageRepositoryMock
- defaultExpectation *ThingImageRepositoryMockAddExpectation
- expectations []*ThingImageRepositoryMockAddExpectation
- callArgs []*ThingImageRepositoryMockAddParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingImageRepositoryMockAddExpectation specifies expectation struct of the ThingImageRepository.Add
- type ThingImageRepositoryMockAddExpectation struct {
- mock *ThingImageRepositoryMock
- params *ThingImageRepositoryMockAddParams
- paramPtrs *ThingImageRepositoryMockAddParamPtrs
- results *ThingImageRepositoryMockAddResults
- Counter uint64
- }
- // ThingImageRepositoryMockAddParams contains parameters of the ThingImageRepository.Add
- type ThingImageRepositoryMockAddParams struct {
- ctx context.Context
- req models.AddThingImageRequest
- }
- // ThingImageRepositoryMockAddParamPtrs contains pointers to parameters of the ThingImageRepository.Add
- type ThingImageRepositoryMockAddParamPtrs struct {
- ctx *context.Context
- req *models.AddThingImageRequest
- }
- // ThingImageRepositoryMockAddResults contains results of the ThingImageRepository.Add
- type ThingImageRepositoryMockAddResults 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 (mmAdd *mThingImageRepositoryMockAdd) Optional() *mThingImageRepositoryMockAdd {
- mmAdd.optional = true
- return mmAdd
- }
- // Expect sets up expected params for ThingImageRepository.Add
- func (mmAdd *mThingImageRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingImageRequest) *mThingImageRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingImageRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.paramPtrs != nil {
- mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by ExpectParams functions")
- }
- mmAdd.defaultExpectation.params = &ThingImageRepositoryMockAddParams{ctx, req}
- for _, e := range mmAdd.expectations {
- if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
- mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
- }
- }
- return mmAdd
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.Add
- func (mmAdd *mThingImageRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingImageRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &ThingImageRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
- return mmAdd
- }
- // ExpectReqParam2 sets up expected param req for ThingImageRepository.Add
- func (mmAdd *mThingImageRepositoryMockAdd) ExpectReqParam2(req models.AddThingImageRequest) *mThingImageRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingImageRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &ThingImageRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.req = &req
- return mmAdd
- }
- // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Add
- func (mmAdd *mThingImageRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingImageRequest)) *mThingImageRepositoryMockAdd {
- if mmAdd.mock.inspectFuncAdd != nil {
- mmAdd.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Add")
- }
- mmAdd.mock.inspectFuncAdd = f
- return mmAdd
- }
- // Return sets up results that will be returned by ThingImageRepository.Add
- func (mmAdd *mThingImageRepositoryMockAdd) Return(err error) *ThingImageRepositoryMock {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingImageRepositoryMockAddExpectation{mock: mmAdd.mock}
- }
- mmAdd.defaultExpectation.results = &ThingImageRepositoryMockAddResults{err}
- return mmAdd.mock
- }
- // Set uses given function f to mock the ThingImageRepository.Add method
- func (mmAdd *mThingImageRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingImageRequest) (err error)) *ThingImageRepositoryMock {
- if mmAdd.defaultExpectation != nil {
- mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Add method")
- }
- if len(mmAdd.expectations) > 0 {
- mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.Add method")
- }
- mmAdd.mock.funcAdd = f
- return mmAdd.mock
- }
- // When sets expectation for the ThingImageRepository.Add which will trigger the result defined by the following
- // Then helper
- func (mmAdd *mThingImageRepositoryMockAdd) When(ctx context.Context, req models.AddThingImageRequest) *ThingImageRepositoryMockAddExpectation {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingImageRepositoryMock.Add mock is already set by Set")
- }
- expectation := &ThingImageRepositoryMockAddExpectation{
- mock: mmAdd.mock,
- params: &ThingImageRepositoryMockAddParams{ctx, req},
- }
- mmAdd.expectations = append(mmAdd.expectations, expectation)
- return expectation
- }
- // Then sets up ThingImageRepository.Add return parameters for the expectation previously defined by the When method
- func (e *ThingImageRepositoryMockAddExpectation) Then(err error) *ThingImageRepositoryMock {
- e.results = &ThingImageRepositoryMockAddResults{err}
- return e.mock
- }
- // Times sets number of times ThingImageRepository.Add should be invoked
- func (mmAdd *mThingImageRepositoryMockAdd) Times(n uint64) *mThingImageRepositoryMockAdd {
- if n == 0 {
- mmAdd.mock.t.Fatalf("Times of ThingImageRepositoryMock.Add mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
- return mmAdd
- }
- func (mmAdd *mThingImageRepositoryMockAdd) invocationsDone() bool {
- if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Add implements image.ThingImageRepository
- func (mmAdd *ThingImageRepositoryMock) Add(ctx context.Context, req models.AddThingImageRequest) (err error) {
- mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
- defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
- if mmAdd.inspectFuncAdd != nil {
- mmAdd.inspectFuncAdd(ctx, req)
- }
- mm_params := ThingImageRepositoryMockAddParams{ctx, req}
- // Record call args
- mmAdd.AddMock.mutex.Lock()
- mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, &mm_params)
- mmAdd.AddMock.mutex.Unlock()
- for _, e := range mmAdd.AddMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.err
- }
- }
- if mmAdd.AddMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
- mm_want := mmAdd.AddMock.defaultExpectation.params
- mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs
- mm_got := ThingImageRepositoryMockAddParams{ctx, req}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmAdd.t.Errorf("ThingImageRepositoryMock.Add 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.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
- mmAdd.t.Errorf("ThingImageRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmAdd.t.Errorf("ThingImageRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmAdd.AddMock.defaultExpectation.results
- if mm_results == nil {
- mmAdd.t.Fatal("No results are set for the ThingImageRepositoryMock.Add")
- }
- return (*mm_results).err
- }
- if mmAdd.funcAdd != nil {
- return mmAdd.funcAdd(ctx, req)
- }
- mmAdd.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Add. %v %v", ctx, req)
- return
- }
- // AddAfterCounter returns a count of finished ThingImageRepositoryMock.Add invocations
- func (mmAdd *ThingImageRepositoryMock) AddAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
- }
- // AddBeforeCounter returns a count of ThingImageRepositoryMock.Add invocations
- func (mmAdd *ThingImageRepositoryMock) AddBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
- }
- // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.Add.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmAdd *mThingImageRepositoryMockAdd) Calls() []*ThingImageRepositoryMockAddParams {
- mmAdd.mutex.RLock()
- argCopy := make([]*ThingImageRepositoryMockAddParams, len(mmAdd.callArgs))
- copy(argCopy, mmAdd.callArgs)
- mmAdd.mutex.RUnlock()
- return argCopy
- }
- // MinimockAddDone returns true if the count of the Add invocations corresponds
- // the number of defined expectations
- func (m *ThingImageRepositoryMock) MinimockAddDone() bool {
- if m.AddMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.AddMock.invocationsDone()
- }
- // MinimockAddInspect logs each unmet expectation
- func (m *ThingImageRepositoryMock) MinimockAddInspect() {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.Add with params: %#v", *e.params)
- }
- }
- afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
- if m.AddMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingImageRepositoryMock.Add")
- } else {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcAdd != nil && afterAddCounter < 1 {
- m.t.Error("Expected call to ThingImageRepositoryMock.Add")
- }
- if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.Add but found %d calls",
- mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
- }
- }
- 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 image.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 mThingImageRepositoryMockGet struct {
- optional bool
- mock *ThingImageRepositoryMock
- defaultExpectation *ThingImageRepositoryMockGetExpectation
- expectations []*ThingImageRepositoryMockGetExpectation
- callArgs []*ThingImageRepositoryMockGetParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingImageRepositoryMockGetExpectation specifies expectation struct of the ThingImageRepository.Get
- type ThingImageRepositoryMockGetExpectation struct {
- mock *ThingImageRepositoryMock
- params *ThingImageRepositoryMockGetParams
- paramPtrs *ThingImageRepositoryMockGetParamPtrs
- results *ThingImageRepositoryMockGetResults
- Counter uint64
- }
- // ThingImageRepositoryMockGetParams contains parameters of the ThingImageRepository.Get
- type ThingImageRepositoryMockGetParams struct {
- ctx context.Context
- id uint64
- }
- // ThingImageRepositoryMockGetParamPtrs contains pointers to parameters of the ThingImageRepository.Get
- type ThingImageRepositoryMockGetParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // ThingImageRepositoryMockGetResults contains results of the ThingImageRepository.Get
- type ThingImageRepositoryMockGetResults struct {
- ip1 *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 (mmGet *mThingImageRepositoryMockGet) Optional() *mThingImageRepositoryMockGet {
- mmGet.optional = true
- return mmGet
- }
- // Expect sets up expected params for ThingImageRepository.Get
- func (mmGet *mThingImageRepositoryMockGet) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingImageRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.paramPtrs != nil {
- mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by ExpectParams functions")
- }
- mmGet.defaultExpectation.params = &ThingImageRepositoryMockGetParams{ctx, id}
- for _, e := range mmGet.expectations {
- if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
- mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
- }
- }
- return mmGet
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.Get
- func (mmGet *mThingImageRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingImageRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGet
- }
- // ExpectIdParam2 sets up expected param id for ThingImageRepository.Get
- func (mmGet *mThingImageRepositoryMockGet) ExpectIdParam2(id uint64) *mThingImageRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingImageRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.id = &id
- return mmGet
- }
- // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.Get
- func (mmGet *mThingImageRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockGet {
- if mmGet.mock.inspectFuncGet != nil {
- mmGet.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.Get")
- }
- mmGet.mock.inspectFuncGet = f
- return mmGet
- }
- // Return sets up results that will be returned by ThingImageRepository.Get
- func (mmGet *mThingImageRepositoryMockGet) Return(ip1 *models.Image, err error) *ThingImageRepositoryMock {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingImageRepositoryMockGetExpectation{mock: mmGet.mock}
- }
- mmGet.defaultExpectation.results = &ThingImageRepositoryMockGetResults{ip1, err}
- return mmGet.mock
- }
- // Set uses given function f to mock the ThingImageRepository.Get method
- func (mmGet *mThingImageRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (ip1 *models.Image, err error)) *ThingImageRepositoryMock {
- if mmGet.defaultExpectation != nil {
- mmGet.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.Get method")
- }
- if len(mmGet.expectations) > 0 {
- mmGet.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.Get method")
- }
- mmGet.mock.funcGet = f
- return mmGet.mock
- }
- // When sets expectation for the ThingImageRepository.Get which will trigger the result defined by the following
- // Then helper
- func (mmGet *mThingImageRepositoryMockGet) When(ctx context.Context, id uint64) *ThingImageRepositoryMockGetExpectation {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingImageRepositoryMock.Get mock is already set by Set")
- }
- expectation := &ThingImageRepositoryMockGetExpectation{
- mock: mmGet.mock,
- params: &ThingImageRepositoryMockGetParams{ctx, id},
- }
- mmGet.expectations = append(mmGet.expectations, expectation)
- return expectation
- }
- // Then sets up ThingImageRepository.Get return parameters for the expectation previously defined by the When method
- func (e *ThingImageRepositoryMockGetExpectation) Then(ip1 *models.Image, err error) *ThingImageRepositoryMock {
- e.results = &ThingImageRepositoryMockGetResults{ip1, err}
- return e.mock
- }
- // Times sets number of times ThingImageRepository.Get should be invoked
- func (mmGet *mThingImageRepositoryMockGet) Times(n uint64) *mThingImageRepositoryMockGet {
- if n == 0 {
- mmGet.mock.t.Fatalf("Times of ThingImageRepositoryMock.Get mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
- return mmGet
- }
- func (mmGet *mThingImageRepositoryMockGet) invocationsDone() bool {
- if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Get implements image.ThingImageRepository
- func (mmGet *ThingImageRepositoryMock) Get(ctx context.Context, id uint64) (ip1 *models.Image, err error) {
- mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
- defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
- if mmGet.inspectFuncGet != nil {
- mmGet.inspectFuncGet(ctx, id)
- }
- mm_params := ThingImageRepositoryMockGetParams{ctx, id}
- // Record call args
- mmGet.GetMock.mutex.Lock()
- mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
- mmGet.GetMock.mutex.Unlock()
- for _, e := range mmGet.GetMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ip1, e.results.err
- }
- }
- if mmGet.GetMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
- mm_want := mmGet.GetMock.defaultExpectation.params
- mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
- mm_got := ThingImageRepositoryMockGetParams{ctx, id}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGet.t.Errorf("ThingImageRepositoryMock.Get 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) {
- mmGet.t.Errorf("ThingImageRepositoryMock.Get 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) {
- mmGet.t.Errorf("ThingImageRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGet.GetMock.defaultExpectation.results
- if mm_results == nil {
- mmGet.t.Fatal("No results are set for the ThingImageRepositoryMock.Get")
- }
- return (*mm_results).ip1, (*mm_results).err
- }
- if mmGet.funcGet != nil {
- return mmGet.funcGet(ctx, id)
- }
- mmGet.t.Fatalf("Unexpected call to ThingImageRepositoryMock.Get. %v %v", ctx, id)
- return
- }
- // GetAfterCounter returns a count of finished ThingImageRepositoryMock.Get invocations
- func (mmGet *ThingImageRepositoryMock) GetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
- }
- // GetBeforeCounter returns a count of ThingImageRepositoryMock.Get invocations
- func (mmGet *ThingImageRepositoryMock) GetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
- }
- // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.Get.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGet *mThingImageRepositoryMockGet) Calls() []*ThingImageRepositoryMockGetParams {
- mmGet.mutex.RLock()
- argCopy := make([]*ThingImageRepositoryMockGetParams, len(mmGet.callArgs))
- copy(argCopy, mmGet.callArgs)
- mmGet.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetDone returns true if the count of the Get invocations corresponds
- // the number of defined expectations
- func (m *ThingImageRepositoryMock) MinimockGetDone() bool {
- if m.GetMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetMock.invocationsDone()
- }
- // MinimockGetInspect logs each unmet expectation
- func (m *ThingImageRepositoryMock) MinimockGetInspect() {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.Get with params: %#v", *e.params)
- }
- }
- afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
- if m.GetMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingImageRepositoryMock.Get")
- } else {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGet != nil && afterGetCounter < 1 {
- m.t.Error("Expected call to ThingImageRepositoryMock.Get")
- }
- if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.Get but found %d calls",
- mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
- }
- }
- type mThingImageRepositoryMockGetByPlaceID struct {
- optional bool
- mock *ThingImageRepositoryMock
- defaultExpectation *ThingImageRepositoryMockGetByPlaceIDExpectation
- expectations []*ThingImageRepositoryMockGetByPlaceIDExpectation
- callArgs []*ThingImageRepositoryMockGetByPlaceIDParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingImageRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingImageRepository.GetByPlaceID
- type ThingImageRepositoryMockGetByPlaceIDExpectation struct {
- mock *ThingImageRepositoryMock
- params *ThingImageRepositoryMockGetByPlaceIDParams
- paramPtrs *ThingImageRepositoryMockGetByPlaceIDParamPtrs
- results *ThingImageRepositoryMockGetByPlaceIDResults
- Counter uint64
- }
- // ThingImageRepositoryMockGetByPlaceIDParams contains parameters of the ThingImageRepository.GetByPlaceID
- type ThingImageRepositoryMockGetByPlaceIDParams struct {
- ctx context.Context
- id uint64
- }
- // ThingImageRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingImageRepository.GetByPlaceID
- type ThingImageRepositoryMockGetByPlaceIDParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // ThingImageRepositoryMockGetByPlaceIDResults contains results of the ThingImageRepository.GetByPlaceID
- type ThingImageRepositoryMockGetByPlaceIDResults 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 (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Optional() *mThingImageRepositoryMockGetByPlaceID {
- mmGetByPlaceID.optional = true
- return mmGetByPlaceID
- }
- // Expect sets up expected params for ThingImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mThingImageRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingImageRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
- }
- mmGetByPlaceID.defaultExpectation.params = &ThingImageRepositoryMockGetByPlaceIDParams{ctx, id}
- for _, e := range mmGetByPlaceID.expectations {
- if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
- mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
- }
- }
- return mmGetByPlaceID
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingImageRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingImageRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.params != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Expect")
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
- mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByPlaceIDParamPtrs{}
- }
- mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetByPlaceID
- }
- // ExpectIdParam2 sets up expected param id for ThingImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mThingImageRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingImageRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.params != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Expect")
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
- mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingImageRepositoryMockGetByPlaceIDParamPtrs{}
- }
- mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
- return mmGetByPlaceID
- }
- // Inspect accepts an inspector function that has same arguments as the ThingImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingImageRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingImageRepositoryMock.GetByPlaceID")
- }
- mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
- return mmGetByPlaceID
- }
- // Return sets up results that will be returned by ThingImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Return(ia1 []models.Image, err error) *ThingImageRepositoryMock {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingImageRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
- }
- mmGetByPlaceID.defaultExpectation.results = &ThingImageRepositoryMockGetByPlaceIDResults{ia1, err}
- return mmGetByPlaceID.mock
- }
- // Set uses given function f to mock the ThingImageRepository.GetByPlaceID method
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *ThingImageRepositoryMock {
- if mmGetByPlaceID.defaultExpectation != nil {
- mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingImageRepository.GetByPlaceID method")
- }
- if len(mmGetByPlaceID.expectations) > 0 {
- mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingImageRepository.GetByPlaceID method")
- }
- mmGetByPlaceID.mock.funcGetByPlaceID = f
- return mmGetByPlaceID.mock
- }
- // When sets expectation for the ThingImageRepository.GetByPlaceID which will trigger the result defined by the following
- // Then helper
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *ThingImageRepositoryMockGetByPlaceIDExpectation {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- expectation := &ThingImageRepositoryMockGetByPlaceIDExpectation{
- mock: mmGetByPlaceID.mock,
- params: &ThingImageRepositoryMockGetByPlaceIDParams{ctx, id},
- }
- mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
- return expectation
- }
- // Then sets up ThingImageRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
- func (e *ThingImageRepositoryMockGetByPlaceIDExpectation) Then(ia1 []models.Image, err error) *ThingImageRepositoryMock {
- e.results = &ThingImageRepositoryMockGetByPlaceIDResults{ia1, err}
- return e.mock
- }
- // Times sets number of times ThingImageRepository.GetByPlaceID should be invoked
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Times(n uint64) *mThingImageRepositoryMockGetByPlaceID {
- if n == 0 {
- mmGetByPlaceID.mock.t.Fatalf("Times of ThingImageRepositoryMock.GetByPlaceID mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
- return mmGetByPlaceID
- }
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) invocationsDone() bool {
- if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetByPlaceID implements image.ThingImageRepository
- func (mmGetByPlaceID *ThingImageRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ia1 []models.Image, err error) {
- mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
- defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
- if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
- mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
- }
- mm_params := ThingImageRepositoryMockGetByPlaceIDParams{ctx, id}
- // Record call args
- mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
- mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params)
- mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()
- for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ia1, e.results.err
- }
- }
- if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
- mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
- mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs
- mm_got := ThingImageRepositoryMockGetByPlaceIDParams{ctx, id}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGetByPlaceID.t.Errorf("ThingImageRepositoryMock.GetByPlaceID 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) {
- mmGetByPlaceID.t.Errorf("ThingImageRepositoryMock.GetByPlaceID 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) {
- mmGetByPlaceID.t.Errorf("ThingImageRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
- if mm_results == nil {
- mmGetByPlaceID.t.Fatal("No results are set for the ThingImageRepositoryMock.GetByPlaceID")
- }
- return (*mm_results).ia1, (*mm_results).err
- }
- if mmGetByPlaceID.funcGetByPlaceID != nil {
- return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
- }
- mmGetByPlaceID.t.Fatalf("Unexpected call to ThingImageRepositoryMock.GetByPlaceID. %v %v", ctx, id)
- return
- }
- // GetByPlaceIDAfterCounter returns a count of finished ThingImageRepositoryMock.GetByPlaceID invocations
- func (mmGetByPlaceID *ThingImageRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
- }
- // GetByPlaceIDBeforeCounter returns a count of ThingImageRepositoryMock.GetByPlaceID invocations
- func (mmGetByPlaceID *ThingImageRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
- }
- // Calls returns a list of arguments used in each call to ThingImageRepositoryMock.GetByPlaceID.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetByPlaceID *mThingImageRepositoryMockGetByPlaceID) Calls() []*ThingImageRepositoryMockGetByPlaceIDParams {
- mmGetByPlaceID.mutex.RLock()
- argCopy := make([]*ThingImageRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
- copy(argCopy, mmGetByPlaceID.callArgs)
- mmGetByPlaceID.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
- // the number of defined expectations
- func (m *ThingImageRepositoryMock) MinimockGetByPlaceIDDone() bool {
- if m.GetByPlaceIDMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetByPlaceIDMock.invocationsDone()
- }
- // MinimockGetByPlaceIDInspect logs each unmet expectation
- func (m *ThingImageRepositoryMock) MinimockGetByPlaceIDInspect() {
- for _, e := range m.GetByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByPlaceID with params: %#v", *e.params)
- }
- }
- afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 {
- if m.GetByPlaceIDMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingImageRepositoryMock.GetByPlaceID")
- } else {
- m.t.Errorf("Expected call to ThingImageRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 {
- m.t.Error("Expected call to ThingImageRepositoryMock.GetByPlaceID")
- }
- if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingImageRepositoryMock.GetByPlaceID but found %d calls",
- mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
- }
- }
- 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 image.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.MinimockAddInspect()
- m.MinimockDeleteInspect()
- m.MinimockGetInspect()
- m.MinimockGetByPlaceIDInspect()
- 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.MinimockAddDone() &&
- m.MinimockDeleteDone() &&
- m.MinimockGetDone() &&
- m.MinimockGetByPlaceIDDone() &&
- m.MinimockGetByThingIDDone()
- }
|