12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391 |
- // Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.
- package mocks
- //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/thing.PlaceThingRepository -o place_thing_repository_minimock.go -n PlaceThingRepositoryMock -p mocks
- import (
- "context"
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "git.dmitriygnatenko.ru/dima/homethings/internal/models"
- "github.com/gojuno/minimock/v3"
- )
- // PlaceThingRepositoryMock implements thing.PlaceThingRepository
- type PlaceThingRepositoryMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcAdd func(ctx context.Context, req models.AddPlaceThingRequest) (err error)
- inspectFuncAdd func(ctx context.Context, req models.AddPlaceThingRequest)
- afterAddCounter uint64
- beforeAddCounter uint64
- AddMock mPlaceThingRepositoryMockAdd
- funcDeleteThing func(ctx context.Context, id uint64) (err error)
- inspectFuncDeleteThing func(ctx context.Context, id uint64)
- afterDeleteThingCounter uint64
- beforeDeleteThingCounter uint64
- DeleteThingMock mPlaceThingRepositoryMockDeleteThing
- funcGetByThingID func(ctx context.Context, id uint64) (pp1 *models.PlaceThing, err error)
- inspectFuncGetByThingID func(ctx context.Context, id uint64)
- afterGetByThingIDCounter uint64
- beforeGetByThingIDCounter uint64
- GetByThingIDMock mPlaceThingRepositoryMockGetByThingID
- funcUpdatePlace func(ctx context.Context, req models.UpdatePlaceThingRequest) (err error)
- inspectFuncUpdatePlace func(ctx context.Context, req models.UpdatePlaceThingRequest)
- afterUpdatePlaceCounter uint64
- beforeUpdatePlaceCounter uint64
- UpdatePlaceMock mPlaceThingRepositoryMockUpdatePlace
- }
- // NewPlaceThingRepositoryMock returns a mock for thing.PlaceThingRepository
- func NewPlaceThingRepositoryMock(t minimock.Tester) *PlaceThingRepositoryMock {
- m := &PlaceThingRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.AddMock = mPlaceThingRepositoryMockAdd{mock: m}
- m.AddMock.callArgs = []*PlaceThingRepositoryMockAddParams{}
- m.DeleteThingMock = mPlaceThingRepositoryMockDeleteThing{mock: m}
- m.DeleteThingMock.callArgs = []*PlaceThingRepositoryMockDeleteThingParams{}
- m.GetByThingIDMock = mPlaceThingRepositoryMockGetByThingID{mock: m}
- m.GetByThingIDMock.callArgs = []*PlaceThingRepositoryMockGetByThingIDParams{}
- m.UpdatePlaceMock = mPlaceThingRepositoryMockUpdatePlace{mock: m}
- m.UpdatePlaceMock.callArgs = []*PlaceThingRepositoryMockUpdatePlaceParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mPlaceThingRepositoryMockAdd struct {
- optional bool
- mock *PlaceThingRepositoryMock
- defaultExpectation *PlaceThingRepositoryMockAddExpectation
- expectations []*PlaceThingRepositoryMockAddExpectation
- callArgs []*PlaceThingRepositoryMockAddParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceThingRepositoryMockAddExpectation specifies expectation struct of the PlaceThingRepository.Add
- type PlaceThingRepositoryMockAddExpectation struct {
- mock *PlaceThingRepositoryMock
- params *PlaceThingRepositoryMockAddParams
- paramPtrs *PlaceThingRepositoryMockAddParamPtrs
- results *PlaceThingRepositoryMockAddResults
- Counter uint64
- }
- // PlaceThingRepositoryMockAddParams contains parameters of the PlaceThingRepository.Add
- type PlaceThingRepositoryMockAddParams struct {
- ctx context.Context
- req models.AddPlaceThingRequest
- }
- // PlaceThingRepositoryMockAddParamPtrs contains pointers to parameters of the PlaceThingRepository.Add
- type PlaceThingRepositoryMockAddParamPtrs struct {
- ctx *context.Context
- req *models.AddPlaceThingRequest
- }
- // PlaceThingRepositoryMockAddResults contains results of the PlaceThingRepository.Add
- type PlaceThingRepositoryMockAddResults 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 *mPlaceThingRepositoryMockAdd) Optional() *mPlaceThingRepositoryMockAdd {
- mmAdd.optional = true
- return mmAdd
- }
- // Expect sets up expected params for PlaceThingRepository.Add
- func (mmAdd *mPlaceThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddPlaceThingRequest) *mPlaceThingRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.paramPtrs != nil {
- mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by ExpectParams functions")
- }
- mmAdd.defaultExpectation.params = &PlaceThingRepositoryMockAddParams{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 PlaceThingRepository.Add
- func (mmAdd *mPlaceThingRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mPlaceThingRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
- return mmAdd
- }
- // ExpectReqParam2 sets up expected param req for PlaceThingRepository.Add
- func (mmAdd *mPlaceThingRepositoryMockAdd) ExpectReqParam2(req models.AddPlaceThingRequest) *mPlaceThingRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.req = &req
- return mmAdd
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.Add
- func (mmAdd *mPlaceThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddPlaceThingRequest)) *mPlaceThingRepositoryMockAdd {
- if mmAdd.mock.inspectFuncAdd != nil {
- mmAdd.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.Add")
- }
- mmAdd.mock.inspectFuncAdd = f
- return mmAdd
- }
- // Return sets up results that will be returned by PlaceThingRepository.Add
- func (mmAdd *mPlaceThingRepositoryMockAdd) Return(err error) *PlaceThingRepositoryMock {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{mock: mmAdd.mock}
- }
- mmAdd.defaultExpectation.results = &PlaceThingRepositoryMockAddResults{err}
- return mmAdd.mock
- }
- // Set uses given function f to mock the PlaceThingRepository.Add method
- func (mmAdd *mPlaceThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddPlaceThingRequest) (err error)) *PlaceThingRepositoryMock {
- if mmAdd.defaultExpectation != nil {
- mmAdd.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.Add method")
- }
- if len(mmAdd.expectations) > 0 {
- mmAdd.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.Add method")
- }
- mmAdd.mock.funcAdd = f
- return mmAdd.mock
- }
- // When sets expectation for the PlaceThingRepository.Add which will trigger the result defined by the following
- // Then helper
- func (mmAdd *mPlaceThingRepositoryMockAdd) When(ctx context.Context, req models.AddPlaceThingRequest) *PlaceThingRepositoryMockAddExpectation {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
- }
- expectation := &PlaceThingRepositoryMockAddExpectation{
- mock: mmAdd.mock,
- params: &PlaceThingRepositoryMockAddParams{ctx, req},
- }
- mmAdd.expectations = append(mmAdd.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceThingRepository.Add return parameters for the expectation previously defined by the When method
- func (e *PlaceThingRepositoryMockAddExpectation) Then(err error) *PlaceThingRepositoryMock {
- e.results = &PlaceThingRepositoryMockAddResults{err}
- return e.mock
- }
- // Times sets number of times PlaceThingRepository.Add should be invoked
- func (mmAdd *mPlaceThingRepositoryMockAdd) Times(n uint64) *mPlaceThingRepositoryMockAdd {
- if n == 0 {
- mmAdd.mock.t.Fatalf("Times of PlaceThingRepositoryMock.Add mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
- return mmAdd
- }
- func (mmAdd *mPlaceThingRepositoryMockAdd) 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 thing.PlaceThingRepository
- func (mmAdd *PlaceThingRepositoryMock) Add(ctx context.Context, req models.AddPlaceThingRequest) (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 := PlaceThingRepositoryMockAddParams{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 := PlaceThingRepositoryMockAddParams{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("PlaceThingRepositoryMock.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("PlaceThingRepositoryMock.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("PlaceThingRepositoryMock.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 PlaceThingRepositoryMock.Add")
- }
- return (*mm_results).err
- }
- if mmAdd.funcAdd != nil {
- return mmAdd.funcAdd(ctx, req)
- }
- mmAdd.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.Add. %v %v", ctx, req)
- return
- }
- // AddAfterCounter returns a count of finished PlaceThingRepositoryMock.Add invocations
- func (mmAdd *PlaceThingRepositoryMock) AddAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
- }
- // AddBeforeCounter returns a count of PlaceThingRepositoryMock.Add invocations
- func (mmAdd *PlaceThingRepositoryMock) AddBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.Add.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmAdd *mPlaceThingRepositoryMockAdd) Calls() []*PlaceThingRepositoryMockAddParams {
- mmAdd.mutex.RLock()
- argCopy := make([]*PlaceThingRepositoryMockAddParams, 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 *PlaceThingRepositoryMock) 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 *PlaceThingRepositoryMock) MinimockAddInspect() {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceThingRepositoryMock.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 PlaceThingRepositoryMock.Add")
- } else {
- m.t.Errorf("Expected call to PlaceThingRepositoryMock.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 PlaceThingRepositoryMock.Add")
- }
- if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceThingRepositoryMock.Add but found %d calls",
- mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
- }
- }
- type mPlaceThingRepositoryMockDeleteThing struct {
- optional bool
- mock *PlaceThingRepositoryMock
- defaultExpectation *PlaceThingRepositoryMockDeleteThingExpectation
- expectations []*PlaceThingRepositoryMockDeleteThingExpectation
- callArgs []*PlaceThingRepositoryMockDeleteThingParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceThingRepositoryMockDeleteThingExpectation specifies expectation struct of the PlaceThingRepository.DeleteThing
- type PlaceThingRepositoryMockDeleteThingExpectation struct {
- mock *PlaceThingRepositoryMock
- params *PlaceThingRepositoryMockDeleteThingParams
- paramPtrs *PlaceThingRepositoryMockDeleteThingParamPtrs
- results *PlaceThingRepositoryMockDeleteThingResults
- Counter uint64
- }
- // PlaceThingRepositoryMockDeleteThingParams contains parameters of the PlaceThingRepository.DeleteThing
- type PlaceThingRepositoryMockDeleteThingParams struct {
- ctx context.Context
- id uint64
- }
- // PlaceThingRepositoryMockDeleteThingParamPtrs contains pointers to parameters of the PlaceThingRepository.DeleteThing
- type PlaceThingRepositoryMockDeleteThingParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // PlaceThingRepositoryMockDeleteThingResults contains results of the PlaceThingRepository.DeleteThing
- type PlaceThingRepositoryMockDeleteThingResults 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 (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Optional() *mPlaceThingRepositoryMockDeleteThing {
- mmDeleteThing.optional = true
- return mmDeleteThing
- }
- // Expect sets up expected params for PlaceThingRepository.DeleteThing
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Context, id uint64) *mPlaceThingRepositoryMockDeleteThing {
- if mmDeleteThing.mock.funcDeleteThing != nil {
- mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
- }
- if mmDeleteThing.defaultExpectation == nil {
- mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
- }
- if mmDeleteThing.defaultExpectation.paramPtrs != nil {
- mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by ExpectParams functions")
- }
- mmDeleteThing.defaultExpectation.params = &PlaceThingRepositoryMockDeleteThingParams{ctx, id}
- for _, e := range mmDeleteThing.expectations {
- if minimock.Equal(e.params, mmDeleteThing.defaultExpectation.params) {
- mmDeleteThing.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteThing.defaultExpectation.params)
- }
- }
- return mmDeleteThing
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceThingRepository.DeleteThing
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectCtxParam1(ctx context.Context) *mPlaceThingRepositoryMockDeleteThing {
- if mmDeleteThing.mock.funcDeleteThing != nil {
- mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
- }
- if mmDeleteThing.defaultExpectation == nil {
- mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
- }
- if mmDeleteThing.defaultExpectation.params != nil {
- mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Expect")
- }
- if mmDeleteThing.defaultExpectation.paramPtrs == nil {
- mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
- }
- mmDeleteThing.defaultExpectation.paramPtrs.ctx = &ctx
- return mmDeleteThing
- }
- // ExpectIdParam2 sets up expected param id for PlaceThingRepository.DeleteThing
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) ExpectIdParam2(id uint64) *mPlaceThingRepositoryMockDeleteThing {
- if mmDeleteThing.mock.funcDeleteThing != nil {
- mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
- }
- if mmDeleteThing.defaultExpectation == nil {
- mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
- }
- if mmDeleteThing.defaultExpectation.params != nil {
- mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Expect")
- }
- if mmDeleteThing.defaultExpectation.paramPtrs == nil {
- mmDeleteThing.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockDeleteThingParamPtrs{}
- }
- mmDeleteThing.defaultExpectation.paramPtrs.id = &id
- return mmDeleteThing
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.DeleteThing
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Inspect(f func(ctx context.Context, id uint64)) *mPlaceThingRepositoryMockDeleteThing {
- if mmDeleteThing.mock.inspectFuncDeleteThing != nil {
- mmDeleteThing.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.DeleteThing")
- }
- mmDeleteThing.mock.inspectFuncDeleteThing = f
- return mmDeleteThing
- }
- // Return sets up results that will be returned by PlaceThingRepository.DeleteThing
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Return(err error) *PlaceThingRepositoryMock {
- if mmDeleteThing.mock.funcDeleteThing != nil {
- mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
- }
- if mmDeleteThing.defaultExpectation == nil {
- mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{mock: mmDeleteThing.mock}
- }
- mmDeleteThing.defaultExpectation.results = &PlaceThingRepositoryMockDeleteThingResults{err}
- return mmDeleteThing.mock
- }
- // Set uses given function f to mock the PlaceThingRepository.DeleteThing method
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx context.Context, id uint64) (err error)) *PlaceThingRepositoryMock {
- if mmDeleteThing.defaultExpectation != nil {
- mmDeleteThing.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.DeleteThing method")
- }
- if len(mmDeleteThing.expectations) > 0 {
- mmDeleteThing.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.DeleteThing method")
- }
- mmDeleteThing.mock.funcDeleteThing = f
- return mmDeleteThing.mock
- }
- // When sets expectation for the PlaceThingRepository.DeleteThing which will trigger the result defined by the following
- // Then helper
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) When(ctx context.Context, id uint64) *PlaceThingRepositoryMockDeleteThingExpectation {
- if mmDeleteThing.mock.funcDeleteThing != nil {
- mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
- }
- expectation := &PlaceThingRepositoryMockDeleteThingExpectation{
- mock: mmDeleteThing.mock,
- params: &PlaceThingRepositoryMockDeleteThingParams{ctx, id},
- }
- mmDeleteThing.expectations = append(mmDeleteThing.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceThingRepository.DeleteThing return parameters for the expectation previously defined by the When method
- func (e *PlaceThingRepositoryMockDeleteThingExpectation) Then(err error) *PlaceThingRepositoryMock {
- e.results = &PlaceThingRepositoryMockDeleteThingResults{err}
- return e.mock
- }
- // Times sets number of times PlaceThingRepository.DeleteThing should be invoked
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Times(n uint64) *mPlaceThingRepositoryMockDeleteThing {
- if n == 0 {
- mmDeleteThing.mock.t.Fatalf("Times of PlaceThingRepositoryMock.DeleteThing mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmDeleteThing.expectedInvocations, n)
- return mmDeleteThing
- }
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) invocationsDone() bool {
- if len(mmDeleteThing.expectations) == 0 && mmDeleteThing.defaultExpectation == nil && mmDeleteThing.mock.funcDeleteThing == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmDeleteThing.mock.afterDeleteThingCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmDeleteThing.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // DeleteThing implements thing.PlaceThingRepository
- func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context, id uint64) (err error) {
- mm_atomic.AddUint64(&mmDeleteThing.beforeDeleteThingCounter, 1)
- defer mm_atomic.AddUint64(&mmDeleteThing.afterDeleteThingCounter, 1)
- if mmDeleteThing.inspectFuncDeleteThing != nil {
- mmDeleteThing.inspectFuncDeleteThing(ctx, id)
- }
- mm_params := PlaceThingRepositoryMockDeleteThingParams{ctx, id}
- // Record call args
- mmDeleteThing.DeleteThingMock.mutex.Lock()
- mmDeleteThing.DeleteThingMock.callArgs = append(mmDeleteThing.DeleteThingMock.callArgs, &mm_params)
- mmDeleteThing.DeleteThingMock.mutex.Unlock()
- for _, e := range mmDeleteThing.DeleteThingMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.err
- }
- }
- if mmDeleteThing.DeleteThingMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmDeleteThing.DeleteThingMock.defaultExpectation.Counter, 1)
- mm_want := mmDeleteThing.DeleteThingMock.defaultExpectation.params
- mm_want_ptrs := mmDeleteThing.DeleteThingMock.defaultExpectation.paramPtrs
- mm_got := PlaceThingRepositoryMockDeleteThingParams{ctx, id}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing 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) {
- mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing 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) {
- mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmDeleteThing.DeleteThingMock.defaultExpectation.results
- if mm_results == nil {
- mmDeleteThing.t.Fatal("No results are set for the PlaceThingRepositoryMock.DeleteThing")
- }
- return (*mm_results).err
- }
- if mmDeleteThing.funcDeleteThing != nil {
- return mmDeleteThing.funcDeleteThing(ctx, id)
- }
- mmDeleteThing.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.DeleteThing. %v %v", ctx, id)
- return
- }
- // DeleteThingAfterCounter returns a count of finished PlaceThingRepositoryMock.DeleteThing invocations
- func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThingAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDeleteThing.afterDeleteThingCounter)
- }
- // DeleteThingBeforeCounter returns a count of PlaceThingRepositoryMock.DeleteThing invocations
- func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThingBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDeleteThing.beforeDeleteThingCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.DeleteThing.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Calls() []*PlaceThingRepositoryMockDeleteThingParams {
- mmDeleteThing.mutex.RLock()
- argCopy := make([]*PlaceThingRepositoryMockDeleteThingParams, len(mmDeleteThing.callArgs))
- copy(argCopy, mmDeleteThing.callArgs)
- mmDeleteThing.mutex.RUnlock()
- return argCopy
- }
- // MinimockDeleteThingDone returns true if the count of the DeleteThing invocations corresponds
- // the number of defined expectations
- func (m *PlaceThingRepositoryMock) MinimockDeleteThingDone() bool {
- if m.DeleteThingMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.DeleteThingMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.DeleteThingMock.invocationsDone()
- }
- // MinimockDeleteThingInspect logs each unmet expectation
- func (m *PlaceThingRepositoryMock) MinimockDeleteThingInspect() {
- for _, e := range m.DeleteThingMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceThingRepositoryMock.DeleteThing with params: %#v", *e.params)
- }
- }
- afterDeleteThingCounter := mm_atomic.LoadUint64(&m.afterDeleteThingCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.DeleteThingMock.defaultExpectation != nil && afterDeleteThingCounter < 1 {
- if m.DeleteThingMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceThingRepositoryMock.DeleteThing")
- } else {
- m.t.Errorf("Expected call to PlaceThingRepositoryMock.DeleteThing with params: %#v", *m.DeleteThingMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcDeleteThing != nil && afterDeleteThingCounter < 1 {
- m.t.Error("Expected call to PlaceThingRepositoryMock.DeleteThing")
- }
- if !m.DeleteThingMock.invocationsDone() && afterDeleteThingCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceThingRepositoryMock.DeleteThing but found %d calls",
- mm_atomic.LoadUint64(&m.DeleteThingMock.expectedInvocations), afterDeleteThingCounter)
- }
- }
- type mPlaceThingRepositoryMockGetByThingID struct {
- optional bool
- mock *PlaceThingRepositoryMock
- defaultExpectation *PlaceThingRepositoryMockGetByThingIDExpectation
- expectations []*PlaceThingRepositoryMockGetByThingIDExpectation
- callArgs []*PlaceThingRepositoryMockGetByThingIDParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceThingRepositoryMockGetByThingIDExpectation specifies expectation struct of the PlaceThingRepository.GetByThingID
- type PlaceThingRepositoryMockGetByThingIDExpectation struct {
- mock *PlaceThingRepositoryMock
- params *PlaceThingRepositoryMockGetByThingIDParams
- paramPtrs *PlaceThingRepositoryMockGetByThingIDParamPtrs
- results *PlaceThingRepositoryMockGetByThingIDResults
- Counter uint64
- }
- // PlaceThingRepositoryMockGetByThingIDParams contains parameters of the PlaceThingRepository.GetByThingID
- type PlaceThingRepositoryMockGetByThingIDParams struct {
- ctx context.Context
- id uint64
- }
- // PlaceThingRepositoryMockGetByThingIDParamPtrs contains pointers to parameters of the PlaceThingRepository.GetByThingID
- type PlaceThingRepositoryMockGetByThingIDParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // PlaceThingRepositoryMockGetByThingIDResults contains results of the PlaceThingRepository.GetByThingID
- type PlaceThingRepositoryMockGetByThingIDResults struct {
- pp1 *models.PlaceThing
- 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 *mPlaceThingRepositoryMockGetByThingID) Optional() *mPlaceThingRepositoryMockGetByThingID {
- mmGetByThingID.optional = true
- return mmGetByThingID
- }
- // Expect sets up expected params for PlaceThingRepository.GetByThingID
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Expect(ctx context.Context, id uint64) *mPlaceThingRepositoryMockGetByThingID {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
- }
- if mmGetByThingID.defaultExpectation == nil {
- mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{}
- }
- if mmGetByThingID.defaultExpectation.paramPtrs != nil {
- mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by ExpectParams functions")
- }
- mmGetByThingID.defaultExpectation.params = &PlaceThingRepositoryMockGetByThingIDParams{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 PlaceThingRepository.GetByThingID
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) ExpectCtxParam1(ctx context.Context) *mPlaceThingRepositoryMockGetByThingID {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
- }
- if mmGetByThingID.defaultExpectation == nil {
- mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{}
- }
- if mmGetByThingID.defaultExpectation.params != nil {
- mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Expect")
- }
- if mmGetByThingID.defaultExpectation.paramPtrs == nil {
- mmGetByThingID.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockGetByThingIDParamPtrs{}
- }
- mmGetByThingID.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetByThingID
- }
- // ExpectIdParam2 sets up expected param id for PlaceThingRepository.GetByThingID
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) ExpectIdParam2(id uint64) *mPlaceThingRepositoryMockGetByThingID {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
- }
- if mmGetByThingID.defaultExpectation == nil {
- mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{}
- }
- if mmGetByThingID.defaultExpectation.params != nil {
- mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Expect")
- }
- if mmGetByThingID.defaultExpectation.paramPtrs == nil {
- mmGetByThingID.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockGetByThingIDParamPtrs{}
- }
- mmGetByThingID.defaultExpectation.paramPtrs.id = &id
- return mmGetByThingID
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.GetByThingID
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, id uint64)) *mPlaceThingRepositoryMockGetByThingID {
- if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.GetByThingID")
- }
- mmGetByThingID.mock.inspectFuncGetByThingID = f
- return mmGetByThingID
- }
- // Return sets up results that will be returned by PlaceThingRepository.GetByThingID
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Return(pp1 *models.PlaceThing, err error) *PlaceThingRepositoryMock {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
- }
- if mmGetByThingID.defaultExpectation == nil {
- mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{mock: mmGetByThingID.mock}
- }
- mmGetByThingID.defaultExpectation.results = &PlaceThingRepositoryMockGetByThingIDResults{pp1, err}
- return mmGetByThingID.mock
- }
- // Set uses given function f to mock the PlaceThingRepository.GetByThingID method
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Set(f func(ctx context.Context, id uint64) (pp1 *models.PlaceThing, err error)) *PlaceThingRepositoryMock {
- if mmGetByThingID.defaultExpectation != nil {
- mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.GetByThingID method")
- }
- if len(mmGetByThingID.expectations) > 0 {
- mmGetByThingID.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.GetByThingID method")
- }
- mmGetByThingID.mock.funcGetByThingID = f
- return mmGetByThingID.mock
- }
- // When sets expectation for the PlaceThingRepository.GetByThingID which will trigger the result defined by the following
- // Then helper
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) When(ctx context.Context, id uint64) *PlaceThingRepositoryMockGetByThingIDExpectation {
- if mmGetByThingID.mock.funcGetByThingID != nil {
- mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
- }
- expectation := &PlaceThingRepositoryMockGetByThingIDExpectation{
- mock: mmGetByThingID.mock,
- params: &PlaceThingRepositoryMockGetByThingIDParams{ctx, id},
- }
- mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceThingRepository.GetByThingID return parameters for the expectation previously defined by the When method
- func (e *PlaceThingRepositoryMockGetByThingIDExpectation) Then(pp1 *models.PlaceThing, err error) *PlaceThingRepositoryMock {
- e.results = &PlaceThingRepositoryMockGetByThingIDResults{pp1, err}
- return e.mock
- }
- // Times sets number of times PlaceThingRepository.GetByThingID should be invoked
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Times(n uint64) *mPlaceThingRepositoryMockGetByThingID {
- if n == 0 {
- mmGetByThingID.mock.t.Fatalf("Times of PlaceThingRepositoryMock.GetByThingID mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetByThingID.expectedInvocations, n)
- return mmGetByThingID
- }
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) invocationsDone() bool {
- if len(mmGetByThingID.expectations) == 0 && mmGetByThingID.defaultExpectation == nil && mmGetByThingID.mock.funcGetByThingID == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetByThingID.mock.afterGetByThingIDCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetByThingID.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetByThingID implements thing.PlaceThingRepository
- func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingID(ctx context.Context, id uint64) (pp1 *models.PlaceThing, 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 := PlaceThingRepositoryMockGetByThingIDParams{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.pp1, 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 := PlaceThingRepositoryMockGetByThingIDParams{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("PlaceThingRepositoryMock.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("PlaceThingRepositoryMock.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("PlaceThingRepositoryMock.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 PlaceThingRepositoryMock.GetByThingID")
- }
- return (*mm_results).pp1, (*mm_results).err
- }
- if mmGetByThingID.funcGetByThingID != nil {
- return mmGetByThingID.funcGetByThingID(ctx, id)
- }
- mmGetByThingID.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.GetByThingID. %v %v", ctx, id)
- return
- }
- // GetByThingIDAfterCounter returns a count of finished PlaceThingRepositoryMock.GetByThingID invocations
- func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingIDAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByThingID.afterGetByThingIDCounter)
- }
- // GetByThingIDBeforeCounter returns a count of PlaceThingRepositoryMock.GetByThingID invocations
- func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingIDBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByThingID.beforeGetByThingIDCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.GetByThingID.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Calls() []*PlaceThingRepositoryMockGetByThingIDParams {
- mmGetByThingID.mutex.RLock()
- argCopy := make([]*PlaceThingRepositoryMockGetByThingIDParams, 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 *PlaceThingRepositoryMock) 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 *PlaceThingRepositoryMock) MinimockGetByThingIDInspect() {
- for _, e := range m.GetByThingIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceThingRepositoryMock.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 PlaceThingRepositoryMock.GetByThingID")
- } else {
- m.t.Errorf("Expected call to PlaceThingRepositoryMock.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 PlaceThingRepositoryMock.GetByThingID")
- }
- if !m.GetByThingIDMock.invocationsDone() && afterGetByThingIDCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceThingRepositoryMock.GetByThingID but found %d calls",
- mm_atomic.LoadUint64(&m.GetByThingIDMock.expectedInvocations), afterGetByThingIDCounter)
- }
- }
- type mPlaceThingRepositoryMockUpdatePlace struct {
- optional bool
- mock *PlaceThingRepositoryMock
- defaultExpectation *PlaceThingRepositoryMockUpdatePlaceExpectation
- expectations []*PlaceThingRepositoryMockUpdatePlaceExpectation
- callArgs []*PlaceThingRepositoryMockUpdatePlaceParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // PlaceThingRepositoryMockUpdatePlaceExpectation specifies expectation struct of the PlaceThingRepository.UpdatePlace
- type PlaceThingRepositoryMockUpdatePlaceExpectation struct {
- mock *PlaceThingRepositoryMock
- params *PlaceThingRepositoryMockUpdatePlaceParams
- paramPtrs *PlaceThingRepositoryMockUpdatePlaceParamPtrs
- results *PlaceThingRepositoryMockUpdatePlaceResults
- Counter uint64
- }
- // PlaceThingRepositoryMockUpdatePlaceParams contains parameters of the PlaceThingRepository.UpdatePlace
- type PlaceThingRepositoryMockUpdatePlaceParams struct {
- ctx context.Context
- req models.UpdatePlaceThingRequest
- }
- // PlaceThingRepositoryMockUpdatePlaceParamPtrs contains pointers to parameters of the PlaceThingRepository.UpdatePlace
- type PlaceThingRepositoryMockUpdatePlaceParamPtrs struct {
- ctx *context.Context
- req *models.UpdatePlaceThingRequest
- }
- // PlaceThingRepositoryMockUpdatePlaceResults contains results of the PlaceThingRepository.UpdatePlace
- type PlaceThingRepositoryMockUpdatePlaceResults 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 (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Optional() *mPlaceThingRepositoryMockUpdatePlace {
- mmUpdatePlace.optional = true
- return mmUpdatePlace
- }
- // Expect sets up expected params for PlaceThingRepository.UpdatePlace
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Expect(ctx context.Context, req models.UpdatePlaceThingRequest) *mPlaceThingRepositoryMockUpdatePlace {
- if mmUpdatePlace.mock.funcUpdatePlace != nil {
- mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
- }
- if mmUpdatePlace.defaultExpectation == nil {
- mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
- }
- if mmUpdatePlace.defaultExpectation.paramPtrs != nil {
- mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by ExpectParams functions")
- }
- mmUpdatePlace.defaultExpectation.params = &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req}
- for _, e := range mmUpdatePlace.expectations {
- if minimock.Equal(e.params, mmUpdatePlace.defaultExpectation.params) {
- mmUpdatePlace.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdatePlace.defaultExpectation.params)
- }
- }
- return mmUpdatePlace
- }
- // ExpectCtxParam1 sets up expected param ctx for PlaceThingRepository.UpdatePlace
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) ExpectCtxParam1(ctx context.Context) *mPlaceThingRepositoryMockUpdatePlace {
- if mmUpdatePlace.mock.funcUpdatePlace != nil {
- mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
- }
- if mmUpdatePlace.defaultExpectation == nil {
- mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
- }
- if mmUpdatePlace.defaultExpectation.params != nil {
- mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Expect")
- }
- if mmUpdatePlace.defaultExpectation.paramPtrs == nil {
- mmUpdatePlace.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockUpdatePlaceParamPtrs{}
- }
- mmUpdatePlace.defaultExpectation.paramPtrs.ctx = &ctx
- return mmUpdatePlace
- }
- // ExpectReqParam2 sets up expected param req for PlaceThingRepository.UpdatePlace
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) ExpectReqParam2(req models.UpdatePlaceThingRequest) *mPlaceThingRepositoryMockUpdatePlace {
- if mmUpdatePlace.mock.funcUpdatePlace != nil {
- mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
- }
- if mmUpdatePlace.defaultExpectation == nil {
- mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
- }
- if mmUpdatePlace.defaultExpectation.params != nil {
- mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Expect")
- }
- if mmUpdatePlace.defaultExpectation.paramPtrs == nil {
- mmUpdatePlace.defaultExpectation.paramPtrs = &PlaceThingRepositoryMockUpdatePlaceParamPtrs{}
- }
- mmUpdatePlace.defaultExpectation.paramPtrs.req = &req
- return mmUpdatePlace
- }
- // Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.UpdatePlace
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Inspect(f func(ctx context.Context, req models.UpdatePlaceThingRequest)) *mPlaceThingRepositoryMockUpdatePlace {
- if mmUpdatePlace.mock.inspectFuncUpdatePlace != nil {
- mmUpdatePlace.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.UpdatePlace")
- }
- mmUpdatePlace.mock.inspectFuncUpdatePlace = f
- return mmUpdatePlace
- }
- // Return sets up results that will be returned by PlaceThingRepository.UpdatePlace
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Return(err error) *PlaceThingRepositoryMock {
- if mmUpdatePlace.mock.funcUpdatePlace != nil {
- mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
- }
- if mmUpdatePlace.defaultExpectation == nil {
- mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{mock: mmUpdatePlace.mock}
- }
- mmUpdatePlace.defaultExpectation.results = &PlaceThingRepositoryMockUpdatePlaceResults{err}
- return mmUpdatePlace.mock
- }
- // Set uses given function f to mock the PlaceThingRepository.UpdatePlace method
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Set(f func(ctx context.Context, req models.UpdatePlaceThingRequest) (err error)) *PlaceThingRepositoryMock {
- if mmUpdatePlace.defaultExpectation != nil {
- mmUpdatePlace.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.UpdatePlace method")
- }
- if len(mmUpdatePlace.expectations) > 0 {
- mmUpdatePlace.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.UpdatePlace method")
- }
- mmUpdatePlace.mock.funcUpdatePlace = f
- return mmUpdatePlace.mock
- }
- // When sets expectation for the PlaceThingRepository.UpdatePlace which will trigger the result defined by the following
- // Then helper
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) When(ctx context.Context, req models.UpdatePlaceThingRequest) *PlaceThingRepositoryMockUpdatePlaceExpectation {
- if mmUpdatePlace.mock.funcUpdatePlace != nil {
- mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
- }
- expectation := &PlaceThingRepositoryMockUpdatePlaceExpectation{
- mock: mmUpdatePlace.mock,
- params: &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req},
- }
- mmUpdatePlace.expectations = append(mmUpdatePlace.expectations, expectation)
- return expectation
- }
- // Then sets up PlaceThingRepository.UpdatePlace return parameters for the expectation previously defined by the When method
- func (e *PlaceThingRepositoryMockUpdatePlaceExpectation) Then(err error) *PlaceThingRepositoryMock {
- e.results = &PlaceThingRepositoryMockUpdatePlaceResults{err}
- return e.mock
- }
- // Times sets number of times PlaceThingRepository.UpdatePlace should be invoked
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Times(n uint64) *mPlaceThingRepositoryMockUpdatePlace {
- if n == 0 {
- mmUpdatePlace.mock.t.Fatalf("Times of PlaceThingRepositoryMock.UpdatePlace mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmUpdatePlace.expectedInvocations, n)
- return mmUpdatePlace
- }
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) invocationsDone() bool {
- if len(mmUpdatePlace.expectations) == 0 && mmUpdatePlace.defaultExpectation == nil && mmUpdatePlace.mock.funcUpdatePlace == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmUpdatePlace.mock.afterUpdatePlaceCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmUpdatePlace.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // UpdatePlace implements thing.PlaceThingRepository
- func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlace(ctx context.Context, req models.UpdatePlaceThingRequest) (err error) {
- mm_atomic.AddUint64(&mmUpdatePlace.beforeUpdatePlaceCounter, 1)
- defer mm_atomic.AddUint64(&mmUpdatePlace.afterUpdatePlaceCounter, 1)
- if mmUpdatePlace.inspectFuncUpdatePlace != nil {
- mmUpdatePlace.inspectFuncUpdatePlace(ctx, req)
- }
- mm_params := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req}
- // Record call args
- mmUpdatePlace.UpdatePlaceMock.mutex.Lock()
- mmUpdatePlace.UpdatePlaceMock.callArgs = append(mmUpdatePlace.UpdatePlaceMock.callArgs, &mm_params)
- mmUpdatePlace.UpdatePlaceMock.mutex.Unlock()
- for _, e := range mmUpdatePlace.UpdatePlaceMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.err
- }
- }
- if mmUpdatePlace.UpdatePlaceMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmUpdatePlace.UpdatePlaceMock.defaultExpectation.Counter, 1)
- mm_want := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.params
- mm_want_ptrs := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.paramPtrs
- mm_got := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace 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) {
- mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace 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) {
- mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.results
- if mm_results == nil {
- mmUpdatePlace.t.Fatal("No results are set for the PlaceThingRepositoryMock.UpdatePlace")
- }
- return (*mm_results).err
- }
- if mmUpdatePlace.funcUpdatePlace != nil {
- return mmUpdatePlace.funcUpdatePlace(ctx, req)
- }
- mmUpdatePlace.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.UpdatePlace. %v %v", ctx, req)
- return
- }
- // UpdatePlaceAfterCounter returns a count of finished PlaceThingRepositoryMock.UpdatePlace invocations
- func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlaceAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdatePlace.afterUpdatePlaceCounter)
- }
- // UpdatePlaceBeforeCounter returns a count of PlaceThingRepositoryMock.UpdatePlace invocations
- func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlaceBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdatePlace.beforeUpdatePlaceCounter)
- }
- // Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.UpdatePlace.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Calls() []*PlaceThingRepositoryMockUpdatePlaceParams {
- mmUpdatePlace.mutex.RLock()
- argCopy := make([]*PlaceThingRepositoryMockUpdatePlaceParams, len(mmUpdatePlace.callArgs))
- copy(argCopy, mmUpdatePlace.callArgs)
- mmUpdatePlace.mutex.RUnlock()
- return argCopy
- }
- // MinimockUpdatePlaceDone returns true if the count of the UpdatePlace invocations corresponds
- // the number of defined expectations
- func (m *PlaceThingRepositoryMock) MinimockUpdatePlaceDone() bool {
- if m.UpdatePlaceMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.UpdatePlaceMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.UpdatePlaceMock.invocationsDone()
- }
- // MinimockUpdatePlaceInspect logs each unmet expectation
- func (m *PlaceThingRepositoryMock) MinimockUpdatePlaceInspect() {
- for _, e := range m.UpdatePlaceMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to PlaceThingRepositoryMock.UpdatePlace with params: %#v", *e.params)
- }
- }
- afterUpdatePlaceCounter := mm_atomic.LoadUint64(&m.afterUpdatePlaceCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.UpdatePlaceMock.defaultExpectation != nil && afterUpdatePlaceCounter < 1 {
- if m.UpdatePlaceMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to PlaceThingRepositoryMock.UpdatePlace")
- } else {
- m.t.Errorf("Expected call to PlaceThingRepositoryMock.UpdatePlace with params: %#v", *m.UpdatePlaceMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcUpdatePlace != nil && afterUpdatePlaceCounter < 1 {
- m.t.Error("Expected call to PlaceThingRepositoryMock.UpdatePlace")
- }
- if !m.UpdatePlaceMock.invocationsDone() && afterUpdatePlaceCounter > 0 {
- m.t.Errorf("Expected %d calls to PlaceThingRepositoryMock.UpdatePlace but found %d calls",
- mm_atomic.LoadUint64(&m.UpdatePlaceMock.expectedInvocations), afterUpdatePlaceCounter)
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *PlaceThingRepositoryMock) MinimockFinish() {
- m.finishOnce.Do(func() {
- if !m.minimockDone() {
- m.MinimockAddInspect()
- m.MinimockDeleteThingInspect()
- m.MinimockGetByThingIDInspect()
- m.MinimockUpdatePlaceInspect()
- }
- })
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *PlaceThingRepositoryMock) 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 *PlaceThingRepositoryMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockAddDone() &&
- m.MinimockDeleteThingDone() &&
- m.MinimockGetByThingIDDone() &&
- m.MinimockUpdatePlaceDone()
- }
|