123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392 |
- // 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.PlaceImageRepository -o place_image_repository_minimock.go -n PlaceImageRepositoryMock -p mocks
- import (
- "context"
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "git.dmitriygnatenko.ru/dima/homethings/internal/models"
- "github.com/gojuno/minimock/v3"
- )
- // PlaceImageRepositoryMock implements image.PlaceImageRepository
- type PlaceImageRepositoryMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcAdd func(ctx context.Context, req models.AddPlaceImageRequest) (err error)
- inspectFuncAdd func(ctx context.Context, req models.AddPlaceImageRequest)
- afterAddCounter uint64
- beforeAddCounter uint64
- AddMock mPlaceImageRepositoryMockAdd
- funcDelete func(ctx context.Context, id uint64) (err error)
- inspectFuncDelete func(ctx context.Context, id uint64)
- afterDeleteCounter uint64
- beforeDeleteCounter uint64
- DeleteMock mPlaceImageRepositoryMockDelete
- funcGet func(ctx context.Context, id uint64) (ip1 *models.Image, err error)
- inspectFuncGet func(ctx context.Context, id uint64)
- afterGetCounter uint64
- beforeGetCounter uint64
- GetMock mPlaceImageRepositoryMockGet
- funcGetByPlaceID func(ctx context.Context, id uint64) (ia1 []models.Image, err error)
- inspectFuncGetByPlaceID func(ctx context.Context, id uint64)
- afterGetByPlaceIDCounter uint64
- beforeGetByPlaceIDCounter uint64
- GetByPlaceIDMock mPlaceImageRepositoryMockGetByPlaceID
- }
- // NewPlaceImageRepositoryMock returns a mock for image.PlaceImageRepository
- func NewPlaceImageRepositoryMock(t minimock.Tester) *PlaceImageRepositoryMock {
- m := &PlaceImageRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.AddMock = mPlaceImageRepositoryMockAdd{mock: m}
- m.AddMock.callArgs = []*PlaceImageRepositoryMockAddParams{}
- m.DeleteMock = mPlaceImageRepositoryMockDelete{mock: m}
- m.DeleteMock.callArgs = []*PlaceImageRepositoryMockDeleteParams{}
- m.GetMock = mPlaceImageRepositoryMockGet{mock: m}
- m.GetMock.callArgs = []*PlaceImageRepositoryMockGetParams{}
- m.GetByPlaceIDMock = mPlaceImageRepositoryMockGetByPlaceID{mock: m}
- m.GetByPlaceIDMock.callArgs = []*PlaceImageRepositoryMockGetByPlaceIDParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mPlaceImageRepositoryMockAdd struct {
- optional bool
- mock *PlaceImageRepositoryMock
- defaultExpectation *PlaceImageRepositoryMockAddExpectation
- expectations []*PlaceImageRepositoryMockAddExpectation
- callArgs []*PlaceImageRepositoryMockAddParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceImageRepositoryMockAddExpectation specifies expectation struct of the PlaceImageRepository.Add
- type PlaceImageRepositoryMockAddExpectation struct {
- mock *PlaceImageRepositoryMock
- params *PlaceImageRepositoryMockAddParams
- paramPtrs *PlaceImageRepositoryMockAddParamPtrs
- results *PlaceImageRepositoryMockAddResults
- Counter uint64
- }
- // PlaceImageRepositoryMockAddParams contains parameters of the PlaceImageRepository.Add
- type PlaceImageRepositoryMockAddParams struct {
- ctx context.Context
- req models.AddPlaceImageRequest
- }
- // PlaceImageRepositoryMockAddParamPtrs contains pointers to parameters of the PlaceImageRepository.Add
- type PlaceImageRepositoryMockAddParamPtrs struct {
- ctx *context.Context
- req *models.AddPlaceImageRequest
- }
- // PlaceImageRepositoryMockAddResults contains results of the PlaceImageRepository.Add
- type PlaceImageRepositoryMockAddResults 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 *mPlaceImageRepositoryMockAdd) Optional() *mPlaceImageRepositoryMockAdd {
- mmAdd.optional = true
- return mmAdd
- }
- // Expect sets up expected params for PlaceImageRepository.Add
- func (mmAdd *mPlaceImageRepositoryMockAdd) Expect(ctx context.Context, req models.AddPlaceImageRequest) *mPlaceImageRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceImageRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceImageRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.paramPtrs != nil {
- mmAdd.mock.t.Fatalf("PlaceImageRepositoryMock.Add mock is already set by ExpectParams functions")
- }
- mmAdd.defaultExpectation.params = &PlaceImageRepositoryMockAddParams{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 PlaceImageRepository.Add
- func (mmAdd *mPlaceImageRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mPlaceImageRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceImageRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceImageRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("PlaceImageRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
- return mmAdd
- }
- // ExpectReqParam2 sets up expected param req for PlaceImageRepository.Add
- func (mmAdd *mPlaceImageRepositoryMockAdd) ExpectReqParam2(req models.AddPlaceImageRequest) *mPlaceImageRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceImageRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceImageRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("PlaceImageRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.req = &req
- return mmAdd
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.Add
- func (mmAdd *mPlaceImageRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddPlaceImageRequest)) *mPlaceImageRepositoryMockAdd {
- if mmAdd.mock.inspectFuncAdd != nil {
- mmAdd.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.Add")
- }
- mmAdd.mock.inspectFuncAdd = f
- return mmAdd
- }
- // Return sets up results that will be returned by PlaceImageRepository.Add
- func (mmAdd *mPlaceImageRepositoryMockAdd) Return(err error) *PlaceImageRepositoryMock {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceImageRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceImageRepositoryMockAddExpectation{mock: mmAdd.mock}
- }
- mmAdd.defaultExpectation.results = &PlaceImageRepositoryMockAddResults{err}
- return mmAdd.mock
- }
- // Set uses given function f to mock the PlaceImageRepository.Add method
- func (mmAdd *mPlaceImageRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddPlaceImageRequest) (err error)) *PlaceImageRepositoryMock {
- if mmAdd.defaultExpectation != nil {
- mmAdd.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.Add method")
- }
- if len(mmAdd.expectations) > 0 {
- mmAdd.mock.t.Fatalf("Some expectations are already set for the PlaceImageRepository.Add method")
- }
- mmAdd.mock.funcAdd = f
- return mmAdd.mock
- }
- // When sets expectation for the PlaceImageRepository.Add which will trigger the result defined by the following
- // Then helper
- func (mmAdd *mPlaceImageRepositoryMockAdd) When(ctx context.Context, req models.AddPlaceImageRequest) *PlaceImageRepositoryMockAddExpectation {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceImageRepositoryMock.Add mock is already set by Set")
- }
- expectation := &PlaceImageRepositoryMockAddExpectation{
- mock: mmAdd.mock,
- params: &PlaceImageRepositoryMockAddParams{ctx, req},
- }
- mmAdd.expectations = append(mmAdd.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceImageRepository.Add return parameters for the expectation previously defined by the When method
- func (e *PlaceImageRepositoryMockAddExpectation) Then(err error) *PlaceImageRepositoryMock {
- e.results = &PlaceImageRepositoryMockAddResults{err}
- return e.mock
- }
- // Times sets number of times PlaceImageRepository.Add should be invoked
- func (mmAdd *mPlaceImageRepositoryMockAdd) Times(n uint64) *mPlaceImageRepositoryMockAdd {
- if n == 0 {
- mmAdd.mock.t.Fatalf("Times of PlaceImageRepositoryMock.Add mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
- return mmAdd
- }
- func (mmAdd *mPlaceImageRepositoryMockAdd) 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.PlaceImageRepository
- func (mmAdd *PlaceImageRepositoryMock) Add(ctx context.Context, req models.AddPlaceImageRequest) (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 := PlaceImageRepositoryMockAddParams{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 := PlaceImageRepositoryMockAddParams{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("PlaceImageRepositoryMock.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("PlaceImageRepositoryMock.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("PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Add")
- }
- return (*mm_results).err
- }
- if mmAdd.funcAdd != nil {
- return mmAdd.funcAdd(ctx, req)
- }
- mmAdd.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.Add. %v %v", ctx, req)
- return
- }
- // AddAfterCounter returns a count of finished PlaceImageRepositoryMock.Add invocations
- func (mmAdd *PlaceImageRepositoryMock) AddAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
- }
- // AddBeforeCounter returns a count of PlaceImageRepositoryMock.Add invocations
- func (mmAdd *PlaceImageRepositoryMock) AddBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceImageRepositoryMock.Add.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmAdd *mPlaceImageRepositoryMockAdd) Calls() []*PlaceImageRepositoryMockAddParams {
- mmAdd.mutex.RLock()
- argCopy := make([]*PlaceImageRepositoryMockAddParams, 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 *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) MinimockAddInspect() {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Add")
- } else {
- m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Add")
- }
- if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceImageRepositoryMock.Add but found %d calls",
- mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
- }
- }
- type mPlaceImageRepositoryMockDelete struct {
- optional bool
- mock *PlaceImageRepositoryMock
- defaultExpectation *PlaceImageRepositoryMockDeleteExpectation
- expectations []*PlaceImageRepositoryMockDeleteExpectation
- callArgs []*PlaceImageRepositoryMockDeleteParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceImageRepositoryMockDeleteExpectation specifies expectation struct of the PlaceImageRepository.Delete
- type PlaceImageRepositoryMockDeleteExpectation struct {
- mock *PlaceImageRepositoryMock
- params *PlaceImageRepositoryMockDeleteParams
- paramPtrs *PlaceImageRepositoryMockDeleteParamPtrs
- results *PlaceImageRepositoryMockDeleteResults
- Counter uint64
- }
- // PlaceImageRepositoryMockDeleteParams contains parameters of the PlaceImageRepository.Delete
- type PlaceImageRepositoryMockDeleteParams struct {
- ctx context.Context
- id uint64
- }
- // PlaceImageRepositoryMockDeleteParamPtrs contains pointers to parameters of the PlaceImageRepository.Delete
- type PlaceImageRepositoryMockDeleteParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // PlaceImageRepositoryMockDeleteResults contains results of the PlaceImageRepository.Delete
- type PlaceImageRepositoryMockDeleteResults 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 *mPlaceImageRepositoryMockDelete) Optional() *mPlaceImageRepositoryMockDelete {
- mmDelete.optional = true
- return mmDelete
- }
- // Expect sets up expected params for PlaceImageRepository.Delete
- func (mmDelete *mPlaceImageRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mPlaceImageRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.paramPtrs != nil {
- mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by ExpectParams functions")
- }
- mmDelete.defaultExpectation.params = &PlaceImageRepositoryMockDeleteParams{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 PlaceImageRepository.Delete
- func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mPlaceImageRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
- return mmDelete
- }
- // ExpectIdParam2 sets up expected param id for PlaceImageRepository.Delete
- func (mmDelete *mPlaceImageRepositoryMockDelete) ExpectIdParam2(id uint64) *mPlaceImageRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.id = &id
- return mmDelete
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.Delete
- func (mmDelete *mPlaceImageRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mPlaceImageRepositoryMockDelete {
- if mmDelete.mock.inspectFuncDelete != nil {
- mmDelete.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.Delete")
- }
- mmDelete.mock.inspectFuncDelete = f
- return mmDelete
- }
- // Return sets up results that will be returned by PlaceImageRepository.Delete
- func (mmDelete *mPlaceImageRepositoryMockDelete) Return(err error) *PlaceImageRepositoryMock {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &PlaceImageRepositoryMockDeleteExpectation{mock: mmDelete.mock}
- }
- mmDelete.defaultExpectation.results = &PlaceImageRepositoryMockDeleteResults{err}
- return mmDelete.mock
- }
- // Set uses given function f to mock the PlaceImageRepository.Delete method
- func (mmDelete *mPlaceImageRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *PlaceImageRepositoryMock {
- if mmDelete.defaultExpectation != nil {
- mmDelete.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.Delete method")
- }
- if len(mmDelete.expectations) > 0 {
- mmDelete.mock.t.Fatalf("Some expectations are already set for the PlaceImageRepository.Delete method")
- }
- mmDelete.mock.funcDelete = f
- return mmDelete.mock
- }
- // When sets expectation for the PlaceImageRepository.Delete which will trigger the result defined by the following
- // Then helper
- func (mmDelete *mPlaceImageRepositoryMockDelete) When(ctx context.Context, id uint64) *PlaceImageRepositoryMockDeleteExpectation {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("PlaceImageRepositoryMock.Delete mock is already set by Set")
- }
- expectation := &PlaceImageRepositoryMockDeleteExpectation{
- mock: mmDelete.mock,
- params: &PlaceImageRepositoryMockDeleteParams{ctx, id},
- }
- mmDelete.expectations = append(mmDelete.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceImageRepository.Delete return parameters for the expectation previously defined by the When method
- func (e *PlaceImageRepositoryMockDeleteExpectation) Then(err error) *PlaceImageRepositoryMock {
- e.results = &PlaceImageRepositoryMockDeleteResults{err}
- return e.mock
- }
- // Times sets number of times PlaceImageRepository.Delete should be invoked
- func (mmDelete *mPlaceImageRepositoryMockDelete) Times(n uint64) *mPlaceImageRepositoryMockDelete {
- if n == 0 {
- mmDelete.mock.t.Fatalf("Times of PlaceImageRepositoryMock.Delete mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
- return mmDelete
- }
- func (mmDelete *mPlaceImageRepositoryMockDelete) 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.PlaceImageRepository
- func (mmDelete *PlaceImageRepositoryMock) 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 := PlaceImageRepositoryMockDeleteParams{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 := PlaceImageRepositoryMockDeleteParams{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("PlaceImageRepositoryMock.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("PlaceImageRepositoryMock.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("PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Delete")
- }
- return (*mm_results).err
- }
- if mmDelete.funcDelete != nil {
- return mmDelete.funcDelete(ctx, id)
- }
- mmDelete.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.Delete. %v %v", ctx, id)
- return
- }
- // DeleteAfterCounter returns a count of finished PlaceImageRepositoryMock.Delete invocations
- func (mmDelete *PlaceImageRepositoryMock) DeleteAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
- }
- // DeleteBeforeCounter returns a count of PlaceImageRepositoryMock.Delete invocations
- func (mmDelete *PlaceImageRepositoryMock) DeleteBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceImageRepositoryMock.Delete.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmDelete *mPlaceImageRepositoryMockDelete) Calls() []*PlaceImageRepositoryMockDeleteParams {
- mmDelete.mutex.RLock()
- argCopy := make([]*PlaceImageRepositoryMockDeleteParams, 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 *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) MinimockDeleteInspect() {
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Delete")
- } else {
- m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Delete")
- }
- if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceImageRepositoryMock.Delete but found %d calls",
- mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
- }
- }
- type mPlaceImageRepositoryMockGet struct {
- optional bool
- mock *PlaceImageRepositoryMock
- defaultExpectation *PlaceImageRepositoryMockGetExpectation
- expectations []*PlaceImageRepositoryMockGetExpectation
- callArgs []*PlaceImageRepositoryMockGetParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceImageRepositoryMockGetExpectation specifies expectation struct of the PlaceImageRepository.Get
- type PlaceImageRepositoryMockGetExpectation struct {
- mock *PlaceImageRepositoryMock
- params *PlaceImageRepositoryMockGetParams
- paramPtrs *PlaceImageRepositoryMockGetParamPtrs
- results *PlaceImageRepositoryMockGetResults
- Counter uint64
- }
- // PlaceImageRepositoryMockGetParams contains parameters of the PlaceImageRepository.Get
- type PlaceImageRepositoryMockGetParams struct {
- ctx context.Context
- id uint64
- }
- // PlaceImageRepositoryMockGetParamPtrs contains pointers to parameters of the PlaceImageRepository.Get
- type PlaceImageRepositoryMockGetParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // PlaceImageRepositoryMockGetResults contains results of the PlaceImageRepository.Get
- type PlaceImageRepositoryMockGetResults 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 *mPlaceImageRepositoryMockGet) Optional() *mPlaceImageRepositoryMockGet {
- mmGet.optional = true
- return mmGet
- }
- // Expect sets up expected params for PlaceImageRepository.Get
- func (mmGet *mPlaceImageRepositoryMockGet) Expect(ctx context.Context, id uint64) *mPlaceImageRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceImageRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &PlaceImageRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.paramPtrs != nil {
- mmGet.mock.t.Fatalf("PlaceImageRepositoryMock.Get mock is already set by ExpectParams functions")
- }
- mmGet.defaultExpectation.params = &PlaceImageRepositoryMockGetParams{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 PlaceImageRepository.Get
- func (mmGet *mPlaceImageRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mPlaceImageRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceImageRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &PlaceImageRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("PlaceImageRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGet
- }
- // ExpectIdParam2 sets up expected param id for PlaceImageRepository.Get
- func (mmGet *mPlaceImageRepositoryMockGet) ExpectIdParam2(id uint64) *mPlaceImageRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceImageRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &PlaceImageRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("PlaceImageRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.id = &id
- return mmGet
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.Get
- func (mmGet *mPlaceImageRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mPlaceImageRepositoryMockGet {
- if mmGet.mock.inspectFuncGet != nil {
- mmGet.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.Get")
- }
- mmGet.mock.inspectFuncGet = f
- return mmGet
- }
- // Return sets up results that will be returned by PlaceImageRepository.Get
- func (mmGet *mPlaceImageRepositoryMockGet) Return(ip1 *models.Image, err error) *PlaceImageRepositoryMock {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceImageRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &PlaceImageRepositoryMockGetExpectation{mock: mmGet.mock}
- }
- mmGet.defaultExpectation.results = &PlaceImageRepositoryMockGetResults{ip1, err}
- return mmGet.mock
- }
- // Set uses given function f to mock the PlaceImageRepository.Get method
- func (mmGet *mPlaceImageRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (ip1 *models.Image, err error)) *PlaceImageRepositoryMock {
- if mmGet.defaultExpectation != nil {
- mmGet.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.Get method")
- }
- if len(mmGet.expectations) > 0 {
- mmGet.mock.t.Fatalf("Some expectations are already set for the PlaceImageRepository.Get method")
- }
- mmGet.mock.funcGet = f
- return mmGet.mock
- }
- // When sets expectation for the PlaceImageRepository.Get which will trigger the result defined by the following
- // Then helper
- func (mmGet *mPlaceImageRepositoryMockGet) When(ctx context.Context, id uint64) *PlaceImageRepositoryMockGetExpectation {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("PlaceImageRepositoryMock.Get mock is already set by Set")
- }
- expectation := &PlaceImageRepositoryMockGetExpectation{
- mock: mmGet.mock,
- params: &PlaceImageRepositoryMockGetParams{ctx, id},
- }
- mmGet.expectations = append(mmGet.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceImageRepository.Get return parameters for the expectation previously defined by the When method
- func (e *PlaceImageRepositoryMockGetExpectation) Then(ip1 *models.Image, err error) *PlaceImageRepositoryMock {
- e.results = &PlaceImageRepositoryMockGetResults{ip1, err}
- return e.mock
- }
- // Times sets number of times PlaceImageRepository.Get should be invoked
- func (mmGet *mPlaceImageRepositoryMockGet) Times(n uint64) *mPlaceImageRepositoryMockGet {
- if n == 0 {
- mmGet.mock.t.Fatalf("Times of PlaceImageRepositoryMock.Get mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
- return mmGet
- }
- func (mmGet *mPlaceImageRepositoryMockGet) 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.PlaceImageRepository
- func (mmGet *PlaceImageRepositoryMock) 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 := PlaceImageRepositoryMockGetParams{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 := PlaceImageRepositoryMockGetParams{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("PlaceImageRepositoryMock.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("PlaceImageRepositoryMock.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("PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Get")
- }
- return (*mm_results).ip1, (*mm_results).err
- }
- if mmGet.funcGet != nil {
- return mmGet.funcGet(ctx, id)
- }
- mmGet.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.Get. %v %v", ctx, id)
- return
- }
- // GetAfterCounter returns a count of finished PlaceImageRepositoryMock.Get invocations
- func (mmGet *PlaceImageRepositoryMock) GetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
- }
- // GetBeforeCounter returns a count of PlaceImageRepositoryMock.Get invocations
- func (mmGet *PlaceImageRepositoryMock) GetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceImageRepositoryMock.Get.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGet *mPlaceImageRepositoryMockGet) Calls() []*PlaceImageRepositoryMockGetParams {
- mmGet.mutex.RLock()
- argCopy := make([]*PlaceImageRepositoryMockGetParams, 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 *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) MinimockGetInspect() {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Get")
- } else {
- m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.Get")
- }
- if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceImageRepositoryMock.Get but found %d calls",
- mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
- }
- }
- type mPlaceImageRepositoryMockGetByPlaceID struct {
- optional bool
- mock *PlaceImageRepositoryMock
- defaultExpectation *PlaceImageRepositoryMockGetByPlaceIDExpectation
- expectations []*PlaceImageRepositoryMockGetByPlaceIDExpectation
- callArgs []*PlaceImageRepositoryMockGetByPlaceIDParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceImageRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the PlaceImageRepository.GetByPlaceID
- type PlaceImageRepositoryMockGetByPlaceIDExpectation struct {
- mock *PlaceImageRepositoryMock
- params *PlaceImageRepositoryMockGetByPlaceIDParams
- paramPtrs *PlaceImageRepositoryMockGetByPlaceIDParamPtrs
- results *PlaceImageRepositoryMockGetByPlaceIDResults
- Counter uint64
- }
- // PlaceImageRepositoryMockGetByPlaceIDParams contains parameters of the PlaceImageRepository.GetByPlaceID
- type PlaceImageRepositoryMockGetByPlaceIDParams struct {
- ctx context.Context
- id uint64
- }
- // PlaceImageRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the PlaceImageRepository.GetByPlaceID
- type PlaceImageRepositoryMockGetByPlaceIDParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // PlaceImageRepositoryMockGetByPlaceIDResults contains results of the PlaceImageRepository.GetByPlaceID
- type PlaceImageRepositoryMockGetByPlaceIDResults 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 *mPlaceImageRepositoryMockGetByPlaceID) Optional() *mPlaceImageRepositoryMockGetByPlaceID {
- mmGetByPlaceID.optional = true
- return mmGetByPlaceID
- }
- // Expect sets up expected params for PlaceImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mPlaceImageRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
- mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
- }
- mmGetByPlaceID.defaultExpectation.params = &PlaceImageRepositoryMockGetByPlaceIDParams{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 PlaceImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mPlaceImageRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.params != nil {
- mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Expect")
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
- mmGetByPlaceID.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetByPlaceIDParamPtrs{}
- }
- mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetByPlaceID
- }
- // ExpectIdParam2 sets up expected param id for PlaceImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mPlaceImageRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{}
- }
- if mmGetByPlaceID.defaultExpectation.params != nil {
- mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Expect")
- }
- if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
- mmGetByPlaceID.defaultExpectation.paramPtrs = &PlaceImageRepositoryMockGetByPlaceIDParamPtrs{}
- }
- mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id
- return mmGetByPlaceID
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mPlaceImageRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for PlaceImageRepositoryMock.GetByPlaceID")
- }
- mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
- return mmGetByPlaceID
- }
- // Return sets up results that will be returned by PlaceImageRepository.GetByPlaceID
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Return(ia1 []models.Image, err error) *PlaceImageRepositoryMock {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &PlaceImageRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
- }
- mmGetByPlaceID.defaultExpectation.results = &PlaceImageRepositoryMockGetByPlaceIDResults{ia1, err}
- return mmGetByPlaceID.mock
- }
- // Set uses given function f to mock the PlaceImageRepository.GetByPlaceID method
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ia1 []models.Image, err error)) *PlaceImageRepositoryMock {
- if mmGetByPlaceID.defaultExpectation != nil {
- mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the PlaceImageRepository.GetByPlaceID method")
- }
- if len(mmGetByPlaceID.expectations) > 0 {
- mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the PlaceImageRepository.GetByPlaceID method")
- }
- mmGetByPlaceID.mock.funcGetByPlaceID = f
- return mmGetByPlaceID.mock
- }
- // When sets expectation for the PlaceImageRepository.GetByPlaceID which will trigger the result defined by the following
- // Then helper
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *PlaceImageRepositoryMockGetByPlaceIDExpectation {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("PlaceImageRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- expectation := &PlaceImageRepositoryMockGetByPlaceIDExpectation{
- mock: mmGetByPlaceID.mock,
- params: &PlaceImageRepositoryMockGetByPlaceIDParams{ctx, id},
- }
- mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceImageRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
- func (e *PlaceImageRepositoryMockGetByPlaceIDExpectation) Then(ia1 []models.Image, err error) *PlaceImageRepositoryMock {
- e.results = &PlaceImageRepositoryMockGetByPlaceIDResults{ia1, err}
- return e.mock
- }
- // Times sets number of times PlaceImageRepository.GetByPlaceID should be invoked
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Times(n uint64) *mPlaceImageRepositoryMockGetByPlaceID {
- if n == 0 {
- mmGetByPlaceID.mock.t.Fatalf("Times of PlaceImageRepositoryMock.GetByPlaceID mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
- return mmGetByPlaceID
- }
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) 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.PlaceImageRepository
- func (mmGetByPlaceID *PlaceImageRepositoryMock) 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 := PlaceImageRepositoryMockGetByPlaceIDParams{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 := PlaceImageRepositoryMockGetByPlaceIDParams{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("PlaceImageRepositoryMock.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("PlaceImageRepositoryMock.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("PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.GetByPlaceID")
- }
- return (*mm_results).ia1, (*mm_results).err
- }
- if mmGetByPlaceID.funcGetByPlaceID != nil {
- return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
- }
- mmGetByPlaceID.t.Fatalf("Unexpected call to PlaceImageRepositoryMock.GetByPlaceID. %v %v", ctx, id)
- return
- }
- // GetByPlaceIDAfterCounter returns a count of finished PlaceImageRepositoryMock.GetByPlaceID invocations
- func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
- }
- // GetByPlaceIDBeforeCounter returns a count of PlaceImageRepositoryMock.GetByPlaceID invocations
- func (mmGetByPlaceID *PlaceImageRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceImageRepositoryMock.GetByPlaceID.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetByPlaceID *mPlaceImageRepositoryMockGetByPlaceID) Calls() []*PlaceImageRepositoryMockGetByPlaceIDParams {
- mmGetByPlaceID.mutex.RLock()
- argCopy := make([]*PlaceImageRepositoryMockGetByPlaceIDParams, 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 *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) MinimockGetByPlaceIDInspect() {
- for _, e := range m.GetByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.GetByPlaceID")
- } else {
- m.t.Errorf("Expected call to PlaceImageRepositoryMock.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 PlaceImageRepositoryMock.GetByPlaceID")
- }
- if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceImageRepositoryMock.GetByPlaceID but found %d calls",
- mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *PlaceImageRepositoryMock) MinimockFinish() {
- m.finishOnce.Do(func() {
- if !m.minimockDone() {
- m.MinimockAddInspect()
- m.MinimockDeleteInspect()
- m.MinimockGetInspect()
- m.MinimockGetByPlaceIDInspect()
- }
- })
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *PlaceImageRepositoryMock) 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 *PlaceImageRepositoryMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockAddDone() &&
- m.MinimockDeleteDone() &&
- m.MinimockGetDone() &&
- m.MinimockGetByPlaceIDDone()
- }
|