123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118 |
- package mocks
- // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
- //go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/interfaces.ThingRepository -o ./mocks/thing_repository_minimock.go -n ThingRepositoryMock
- import (
- "context"
- "database/sql"
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "git.dmitriygnatenko.ru/dima/homethings/internal/models"
- "github.com/gojuno/minimock/v3"
- )
- // ThingRepositoryMock implements interfaces.ThingRepository
- type ThingRepositoryMock struct {
- t minimock.Tester
- funcAdd func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error)
- inspectFuncAdd func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx)
- afterAddCounter uint64
- beforeAddCounter uint64
- AddMock mThingRepositoryMockAdd
- funcBeginTx func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)
- inspectFuncBeginTx func(ctx context.Context, level sql.IsolationLevel)
- afterBeginTxCounter uint64
- beforeBeginTxCounter uint64
- BeginTxMock mThingRepositoryMockBeginTx
- funcCommitTx func(tx *sql.Tx) (err error)
- inspectFuncCommitTx func(tx *sql.Tx)
- afterCommitTxCounter uint64
- beforeCommitTxCounter uint64
- CommitTxMock mThingRepositoryMockCommitTx
- funcDelete func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
- inspectFuncDelete func(ctx context.Context, thingID int, tx *sql.Tx)
- afterDeleteCounter uint64
- beforeDeleteCounter uint64
- DeleteMock mThingRepositoryMockDelete
- funcGet func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)
- inspectFuncGet func(ctx context.Context, thingID int)
- afterGetCounter uint64
- beforeGetCounter uint64
- GetMock mThingRepositoryMockGet
- funcGetAllByPlaceID func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
- inspectFuncGetAllByPlaceID func(ctx context.Context, placeID int)
- afterGetAllByPlaceIDCounter uint64
- beforeGetAllByPlaceIDCounter uint64
- GetAllByPlaceIDMock mThingRepositoryMockGetAllByPlaceID
- funcGetByPlaceID func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)
- inspectFuncGetByPlaceID func(ctx context.Context, placeID int)
- afterGetByPlaceIDCounter uint64
- beforeGetByPlaceIDCounter uint64
- GetByPlaceIDMock mThingRepositoryMockGetByPlaceID
- funcSearch func(ctx context.Context, search string) (ta1 []models.Thing, err error)
- inspectFuncSearch func(ctx context.Context, search string)
- afterSearchCounter uint64
- beforeSearchCounter uint64
- SearchMock mThingRepositoryMockSearch
- funcUpdate func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error)
- inspectFuncUpdate func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx)
- afterUpdateCounter uint64
- beforeUpdateCounter uint64
- UpdateMock mThingRepositoryMockUpdate
- }
- // NewThingRepositoryMock returns a mock for interfaces.ThingRepository
- func NewThingRepositoryMock(t minimock.Tester) *ThingRepositoryMock {
- m := &ThingRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.AddMock = mThingRepositoryMockAdd{mock: m}
- m.AddMock.callArgs = []*ThingRepositoryMockAddParams{}
- m.BeginTxMock = mThingRepositoryMockBeginTx{mock: m}
- m.BeginTxMock.callArgs = []*ThingRepositoryMockBeginTxParams{}
- m.CommitTxMock = mThingRepositoryMockCommitTx{mock: m}
- m.CommitTxMock.callArgs = []*ThingRepositoryMockCommitTxParams{}
- m.DeleteMock = mThingRepositoryMockDelete{mock: m}
- m.DeleteMock.callArgs = []*ThingRepositoryMockDeleteParams{}
- m.GetMock = mThingRepositoryMockGet{mock: m}
- m.GetMock.callArgs = []*ThingRepositoryMockGetParams{}
- m.GetAllByPlaceIDMock = mThingRepositoryMockGetAllByPlaceID{mock: m}
- m.GetAllByPlaceIDMock.callArgs = []*ThingRepositoryMockGetAllByPlaceIDParams{}
- m.GetByPlaceIDMock = mThingRepositoryMockGetByPlaceID{mock: m}
- m.GetByPlaceIDMock.callArgs = []*ThingRepositoryMockGetByPlaceIDParams{}
- m.SearchMock = mThingRepositoryMockSearch{mock: m}
- m.SearchMock.callArgs = []*ThingRepositoryMockSearchParams{}
- m.UpdateMock = mThingRepositoryMockUpdate{mock: m}
- m.UpdateMock.callArgs = []*ThingRepositoryMockUpdateParams{}
- return m
- }
- type mThingRepositoryMockAdd struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockAddExpectation
- expectations []*ThingRepositoryMockAddExpectation
- callArgs []*ThingRepositoryMockAddParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockAddExpectation specifies expectation struct of the ThingRepository.Add
- type ThingRepositoryMockAddExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockAddParams
- results *ThingRepositoryMockAddResults
- Counter uint64
- }
- // ThingRepositoryMockAddParams contains parameters of the ThingRepository.Add
- type ThingRepositoryMockAddParams struct {
- ctx context.Context
- req models.AddThingRequest
- tx *sql.Tx
- }
- // ThingRepositoryMockAddResults contains results of the ThingRepository.Add
- type ThingRepositoryMockAddResults struct {
- i1 int
- err error
- }
- // Expect sets up expected params for ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) *mThingRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
- }
- mmAdd.defaultExpectation.params = &ThingRepositoryMockAddParams{ctx, req, tx}
- 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
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx)) *mThingRepositoryMockAdd {
- if mmAdd.mock.inspectFuncAdd != nil {
- mmAdd.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Add")
- }
- mmAdd.mock.inspectFuncAdd = f
- return mmAdd
- }
- // Return sets up results that will be returned by ThingRepository.Add
- func (mmAdd *mThingRepositoryMockAdd) Return(i1 int, err error) *ThingRepositoryMock {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{mock: mmAdd.mock}
- }
- mmAdd.defaultExpectation.results = &ThingRepositoryMockAddResults{i1, err}
- return mmAdd.mock
- }
- // Set uses given function f to mock the ThingRepository.Add method
- func (mmAdd *mThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error)) *ThingRepositoryMock {
- if mmAdd.defaultExpectation != nil {
- mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Add method")
- }
- if len(mmAdd.expectations) > 0 {
- mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Add method")
- }
- mmAdd.mock.funcAdd = f
- return mmAdd.mock
- }
- // When sets expectation for the ThingRepository.Add which will trigger the result defined by the following
- // Then helper
- func (mmAdd *mThingRepositoryMockAdd) When(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) *ThingRepositoryMockAddExpectation {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
- }
- expectation := &ThingRepositoryMockAddExpectation{
- mock: mmAdd.mock,
- params: &ThingRepositoryMockAddParams{ctx, req, tx},
- }
- mmAdd.expectations = append(mmAdd.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Add return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockAddExpectation) Then(i1 int, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockAddResults{i1, err}
- return e.mock
- }
- // Add implements interfaces.ThingRepository
- func (mmAdd *ThingRepositoryMock) Add(ctx context.Context, req models.AddThingRequest, tx *sql.Tx) (i1 int, err error) {
- mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
- defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
- if mmAdd.inspectFuncAdd != nil {
- mmAdd.inspectFuncAdd(ctx, req, tx)
- }
- mm_params := &ThingRepositoryMockAddParams{ctx, req, tx}
- // 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.i1, e.results.err
- }
- }
- if mmAdd.AddMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
- mm_want := mmAdd.AddMock.defaultExpectation.params
- mm_got := ThingRepositoryMockAddParams{ctx, req, tx}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmAdd.t.Errorf("ThingRepositoryMock.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 ThingRepositoryMock.Add")
- }
- return (*mm_results).i1, (*mm_results).err
- }
- if mmAdd.funcAdd != nil {
- return mmAdd.funcAdd(ctx, req, tx)
- }
- mmAdd.t.Fatalf("Unexpected call to ThingRepositoryMock.Add. %v %v %v", ctx, req, tx)
- return
- }
- // AddAfterCounter returns a count of finished ThingRepositoryMock.Add invocations
- func (mmAdd *ThingRepositoryMock) AddAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
- }
- // AddBeforeCounter returns a count of ThingRepositoryMock.Add invocations
- func (mmAdd *ThingRepositoryMock) AddBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Add.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmAdd *mThingRepositoryMockAdd) Calls() []*ThingRepositoryMockAddParams {
- mmAdd.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockAddParams, 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 *ThingRepositoryMock) MinimockAddDone() bool {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockAddInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockAddInspect() {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
- if m.AddMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.Add")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.Add")
- }
- }
- type mThingRepositoryMockBeginTx struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockBeginTxExpectation
- expectations []*ThingRepositoryMockBeginTxExpectation
- callArgs []*ThingRepositoryMockBeginTxParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockBeginTxExpectation specifies expectation struct of the ThingRepository.BeginTx
- type ThingRepositoryMockBeginTxExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockBeginTxParams
- results *ThingRepositoryMockBeginTxResults
- Counter uint64
- }
- // ThingRepositoryMockBeginTxParams contains parameters of the ThingRepository.BeginTx
- type ThingRepositoryMockBeginTxParams struct {
- ctx context.Context
- level sql.IsolationLevel
- }
- // ThingRepositoryMockBeginTxResults contains results of the ThingRepository.BeginTx
- type ThingRepositoryMockBeginTxResults struct {
- tp1 *sql.Tx
- err error
- }
- // Expect sets up expected params for ThingRepository.BeginTx
- func (mmBeginTx *mThingRepositoryMockBeginTx) Expect(ctx context.Context, level sql.IsolationLevel) *mThingRepositoryMockBeginTx {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{}
- }
- mmBeginTx.defaultExpectation.params = &ThingRepositoryMockBeginTxParams{ctx, level}
- for _, e := range mmBeginTx.expectations {
- if minimock.Equal(e.params, mmBeginTx.defaultExpectation.params) {
- mmBeginTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmBeginTx.defaultExpectation.params)
- }
- }
- return mmBeginTx
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.BeginTx
- func (mmBeginTx *mThingRepositoryMockBeginTx) Inspect(f func(ctx context.Context, level sql.IsolationLevel)) *mThingRepositoryMockBeginTx {
- if mmBeginTx.mock.inspectFuncBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.BeginTx")
- }
- mmBeginTx.mock.inspectFuncBeginTx = f
- return mmBeginTx
- }
- // Return sets up results that will be returned by ThingRepository.BeginTx
- func (mmBeginTx *mThingRepositoryMockBeginTx) Return(tp1 *sql.Tx, err error) *ThingRepositoryMock {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
- }
- if mmBeginTx.defaultExpectation == nil {
- mmBeginTx.defaultExpectation = &ThingRepositoryMockBeginTxExpectation{mock: mmBeginTx.mock}
- }
- mmBeginTx.defaultExpectation.results = &ThingRepositoryMockBeginTxResults{tp1, err}
- return mmBeginTx.mock
- }
- // Set uses given function f to mock the ThingRepository.BeginTx method
- func (mmBeginTx *mThingRepositoryMockBeginTx) Set(f func(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error)) *ThingRepositoryMock {
- if mmBeginTx.defaultExpectation != nil {
- mmBeginTx.mock.t.Fatalf("Default expectation is already set for the ThingRepository.BeginTx method")
- }
- if len(mmBeginTx.expectations) > 0 {
- mmBeginTx.mock.t.Fatalf("Some expectations are already set for the ThingRepository.BeginTx method")
- }
- mmBeginTx.mock.funcBeginTx = f
- return mmBeginTx.mock
- }
- // When sets expectation for the ThingRepository.BeginTx which will trigger the result defined by the following
- // Then helper
- func (mmBeginTx *mThingRepositoryMockBeginTx) When(ctx context.Context, level sql.IsolationLevel) *ThingRepositoryMockBeginTxExpectation {
- if mmBeginTx.mock.funcBeginTx != nil {
- mmBeginTx.mock.t.Fatalf("ThingRepositoryMock.BeginTx mock is already set by Set")
- }
- expectation := &ThingRepositoryMockBeginTxExpectation{
- mock: mmBeginTx.mock,
- params: &ThingRepositoryMockBeginTxParams{ctx, level},
- }
- mmBeginTx.expectations = append(mmBeginTx.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.BeginTx return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockBeginTxExpectation) Then(tp1 *sql.Tx, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockBeginTxResults{tp1, err}
- return e.mock
- }
- // BeginTx implements interfaces.ThingRepository
- func (mmBeginTx *ThingRepositoryMock) BeginTx(ctx context.Context, level sql.IsolationLevel) (tp1 *sql.Tx, err error) {
- mm_atomic.AddUint64(&mmBeginTx.beforeBeginTxCounter, 1)
- defer mm_atomic.AddUint64(&mmBeginTx.afterBeginTxCounter, 1)
- if mmBeginTx.inspectFuncBeginTx != nil {
- mmBeginTx.inspectFuncBeginTx(ctx, level)
- }
- mm_params := &ThingRepositoryMockBeginTxParams{ctx, level}
- // Record call args
- mmBeginTx.BeginTxMock.mutex.Lock()
- mmBeginTx.BeginTxMock.callArgs = append(mmBeginTx.BeginTxMock.callArgs, mm_params)
- mmBeginTx.BeginTxMock.mutex.Unlock()
- for _, e := range mmBeginTx.BeginTxMock.expectations {
- if minimock.Equal(e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.tp1, e.results.err
- }
- }
- if mmBeginTx.BeginTxMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmBeginTx.BeginTxMock.defaultExpectation.Counter, 1)
- mm_want := mmBeginTx.BeginTxMock.defaultExpectation.params
- mm_got := ThingRepositoryMockBeginTxParams{ctx, level}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmBeginTx.t.Errorf("ThingRepositoryMock.BeginTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmBeginTx.BeginTxMock.defaultExpectation.results
- if mm_results == nil {
- mmBeginTx.t.Fatal("No results are set for the ThingRepositoryMock.BeginTx")
- }
- return (*mm_results).tp1, (*mm_results).err
- }
- if mmBeginTx.funcBeginTx != nil {
- return mmBeginTx.funcBeginTx(ctx, level)
- }
- mmBeginTx.t.Fatalf("Unexpected call to ThingRepositoryMock.BeginTx. %v %v", ctx, level)
- return
- }
- // BeginTxAfterCounter returns a count of finished ThingRepositoryMock.BeginTx invocations
- func (mmBeginTx *ThingRepositoryMock) BeginTxAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmBeginTx.afterBeginTxCounter)
- }
- // BeginTxBeforeCounter returns a count of ThingRepositoryMock.BeginTx invocations
- func (mmBeginTx *ThingRepositoryMock) BeginTxBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmBeginTx.beforeBeginTxCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.BeginTx.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmBeginTx *mThingRepositoryMockBeginTx) Calls() []*ThingRepositoryMockBeginTxParams {
- mmBeginTx.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockBeginTxParams, len(mmBeginTx.callArgs))
- copy(argCopy, mmBeginTx.callArgs)
- mmBeginTx.mutex.RUnlock()
- return argCopy
- }
- // MinimockBeginTxDone returns true if the count of the BeginTx invocations corresponds
- // the number of defined expectations
- func (m *ThingRepositoryMock) MinimockBeginTxDone() bool {
- for _, e := range m.BeginTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.BeginTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcBeginTx != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockBeginTxInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockBeginTxInspect() {
- for _, e := range m.BeginTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.BeginTx with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.BeginTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
- if m.BeginTxMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.BeginTx")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.BeginTx with params: %#v", *m.BeginTxMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcBeginTx != nil && mm_atomic.LoadUint64(&m.afterBeginTxCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.BeginTx")
- }
- }
- type mThingRepositoryMockCommitTx struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockCommitTxExpectation
- expectations []*ThingRepositoryMockCommitTxExpectation
- callArgs []*ThingRepositoryMockCommitTxParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockCommitTxExpectation specifies expectation struct of the ThingRepository.CommitTx
- type ThingRepositoryMockCommitTxExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockCommitTxParams
- results *ThingRepositoryMockCommitTxResults
- Counter uint64
- }
- // ThingRepositoryMockCommitTxParams contains parameters of the ThingRepository.CommitTx
- type ThingRepositoryMockCommitTxParams struct {
- tx *sql.Tx
- }
- // ThingRepositoryMockCommitTxResults contains results of the ThingRepository.CommitTx
- type ThingRepositoryMockCommitTxResults struct {
- err error
- }
- // Expect sets up expected params for ThingRepository.CommitTx
- func (mmCommitTx *mThingRepositoryMockCommitTx) Expect(tx *sql.Tx) *mThingRepositoryMockCommitTx {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
- }
- if mmCommitTx.defaultExpectation == nil {
- mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{}
- }
- mmCommitTx.defaultExpectation.params = &ThingRepositoryMockCommitTxParams{tx}
- for _, e := range mmCommitTx.expectations {
- if minimock.Equal(e.params, mmCommitTx.defaultExpectation.params) {
- mmCommitTx.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCommitTx.defaultExpectation.params)
- }
- }
- return mmCommitTx
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.CommitTx
- func (mmCommitTx *mThingRepositoryMockCommitTx) Inspect(f func(tx *sql.Tx)) *mThingRepositoryMockCommitTx {
- if mmCommitTx.mock.inspectFuncCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.CommitTx")
- }
- mmCommitTx.mock.inspectFuncCommitTx = f
- return mmCommitTx
- }
- // Return sets up results that will be returned by ThingRepository.CommitTx
- func (mmCommitTx *mThingRepositoryMockCommitTx) Return(err error) *ThingRepositoryMock {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
- }
- if mmCommitTx.defaultExpectation == nil {
- mmCommitTx.defaultExpectation = &ThingRepositoryMockCommitTxExpectation{mock: mmCommitTx.mock}
- }
- mmCommitTx.defaultExpectation.results = &ThingRepositoryMockCommitTxResults{err}
- return mmCommitTx.mock
- }
- // Set uses given function f to mock the ThingRepository.CommitTx method
- func (mmCommitTx *mThingRepositoryMockCommitTx) Set(f func(tx *sql.Tx) (err error)) *ThingRepositoryMock {
- if mmCommitTx.defaultExpectation != nil {
- mmCommitTx.mock.t.Fatalf("Default expectation is already set for the ThingRepository.CommitTx method")
- }
- if len(mmCommitTx.expectations) > 0 {
- mmCommitTx.mock.t.Fatalf("Some expectations are already set for the ThingRepository.CommitTx method")
- }
- mmCommitTx.mock.funcCommitTx = f
- return mmCommitTx.mock
- }
- // When sets expectation for the ThingRepository.CommitTx which will trigger the result defined by the following
- // Then helper
- func (mmCommitTx *mThingRepositoryMockCommitTx) When(tx *sql.Tx) *ThingRepositoryMockCommitTxExpectation {
- if mmCommitTx.mock.funcCommitTx != nil {
- mmCommitTx.mock.t.Fatalf("ThingRepositoryMock.CommitTx mock is already set by Set")
- }
- expectation := &ThingRepositoryMockCommitTxExpectation{
- mock: mmCommitTx.mock,
- params: &ThingRepositoryMockCommitTxParams{tx},
- }
- mmCommitTx.expectations = append(mmCommitTx.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.CommitTx return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockCommitTxExpectation) Then(err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockCommitTxResults{err}
- return e.mock
- }
- // CommitTx implements interfaces.ThingRepository
- func (mmCommitTx *ThingRepositoryMock) CommitTx(tx *sql.Tx) (err error) {
- mm_atomic.AddUint64(&mmCommitTx.beforeCommitTxCounter, 1)
- defer mm_atomic.AddUint64(&mmCommitTx.afterCommitTxCounter, 1)
- if mmCommitTx.inspectFuncCommitTx != nil {
- mmCommitTx.inspectFuncCommitTx(tx)
- }
- mm_params := &ThingRepositoryMockCommitTxParams{tx}
- // Record call args
- mmCommitTx.CommitTxMock.mutex.Lock()
- mmCommitTx.CommitTxMock.callArgs = append(mmCommitTx.CommitTxMock.callArgs, mm_params)
- mmCommitTx.CommitTxMock.mutex.Unlock()
- for _, e := range mmCommitTx.CommitTxMock.expectations {
- if minimock.Equal(e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.err
- }
- }
- if mmCommitTx.CommitTxMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmCommitTx.CommitTxMock.defaultExpectation.Counter, 1)
- mm_want := mmCommitTx.CommitTxMock.defaultExpectation.params
- mm_got := ThingRepositoryMockCommitTxParams{tx}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmCommitTx.t.Errorf("ThingRepositoryMock.CommitTx got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmCommitTx.CommitTxMock.defaultExpectation.results
- if mm_results == nil {
- mmCommitTx.t.Fatal("No results are set for the ThingRepositoryMock.CommitTx")
- }
- return (*mm_results).err
- }
- if mmCommitTx.funcCommitTx != nil {
- return mmCommitTx.funcCommitTx(tx)
- }
- mmCommitTx.t.Fatalf("Unexpected call to ThingRepositoryMock.CommitTx. %v", tx)
- return
- }
- // CommitTxAfterCounter returns a count of finished ThingRepositoryMock.CommitTx invocations
- func (mmCommitTx *ThingRepositoryMock) CommitTxAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmCommitTx.afterCommitTxCounter)
- }
- // CommitTxBeforeCounter returns a count of ThingRepositoryMock.CommitTx invocations
- func (mmCommitTx *ThingRepositoryMock) CommitTxBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmCommitTx.beforeCommitTxCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.CommitTx.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmCommitTx *mThingRepositoryMockCommitTx) Calls() []*ThingRepositoryMockCommitTxParams {
- mmCommitTx.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockCommitTxParams, len(mmCommitTx.callArgs))
- copy(argCopy, mmCommitTx.callArgs)
- mmCommitTx.mutex.RUnlock()
- return argCopy
- }
- // MinimockCommitTxDone returns true if the count of the CommitTx invocations corresponds
- // the number of defined expectations
- func (m *ThingRepositoryMock) MinimockCommitTxDone() bool {
- for _, e := range m.CommitTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.CommitTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcCommitTx != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockCommitTxInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockCommitTxInspect() {
- for _, e := range m.CommitTxMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.CommitTx with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.CommitTxMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
- if m.CommitTxMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.CommitTx")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.CommitTx with params: %#v", *m.CommitTxMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcCommitTx != nil && mm_atomic.LoadUint64(&m.afterCommitTxCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.CommitTx")
- }
- }
- type mThingRepositoryMockDelete struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockDeleteExpectation
- expectations []*ThingRepositoryMockDeleteExpectation
- callArgs []*ThingRepositoryMockDeleteParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockDeleteExpectation specifies expectation struct of the ThingRepository.Delete
- type ThingRepositoryMockDeleteExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockDeleteParams
- results *ThingRepositoryMockDeleteResults
- Counter uint64
- }
- // ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete
- type ThingRepositoryMockDeleteParams struct {
- ctx context.Context
- thingID int
- tx *sql.Tx
- }
- // ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete
- type ThingRepositoryMockDeleteResults struct {
- err error
- }
- // Expect sets up expected params for ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mThingRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
- }
- mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, thingID, tx}
- 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
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mThingRepositoryMockDelete {
- if mmDelete.mock.inspectFuncDelete != nil {
- mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete")
- }
- mmDelete.mock.inspectFuncDelete = f
- return mmDelete
- }
- // Return sets up results that will be returned by ThingRepository.Delete
- func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMock {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{mock: mmDelete.mock}
- }
- mmDelete.defaultExpectation.results = &ThingRepositoryMockDeleteResults{err}
- return mmDelete.mock
- }
- // Set uses given function f to mock the ThingRepository.Delete method
- func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *ThingRepositoryMock {
- if mmDelete.defaultExpectation != nil {
- mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method")
- }
- if len(mmDelete.expectations) > 0 {
- mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Delete method")
- }
- mmDelete.mock.funcDelete = f
- return mmDelete.mock
- }
- // When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following
- // Then helper
- func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, thingID int, tx *sql.Tx) *ThingRepositoryMockDeleteExpectation {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
- }
- expectation := &ThingRepositoryMockDeleteExpectation{
- mock: mmDelete.mock,
- params: &ThingRepositoryMockDeleteParams{ctx, thingID, tx},
- }
- mmDelete.expectations = append(mmDelete.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Delete return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockDeleteExpectation) Then(err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockDeleteResults{err}
- return e.mock
- }
- // Delete implements interfaces.ThingRepository
- func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
- mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
- defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
- if mmDelete.inspectFuncDelete != nil {
- mmDelete.inspectFuncDelete(ctx, thingID, tx)
- }
- mm_params := &ThingRepositoryMockDeleteParams{ctx, thingID, tx}
- // 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_got := ThingRepositoryMockDeleteParams{ctx, thingID, tx}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmDelete.t.Errorf("ThingRepositoryMock.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 ThingRepositoryMock.Delete")
- }
- return (*mm_results).err
- }
- if mmDelete.funcDelete != nil {
- return mmDelete.funcDelete(ctx, thingID, tx)
- }
- mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v %v", ctx, thingID, tx)
- return
- }
- // DeleteAfterCounter returns a count of finished ThingRepositoryMock.Delete invocations
- func (mmDelete *ThingRepositoryMock) DeleteAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
- }
- // DeleteBeforeCounter returns a count of ThingRepositoryMock.Delete invocations
- func (mmDelete *ThingRepositoryMock) DeleteBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Delete.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmDelete *mThingRepositoryMockDelete) Calls() []*ThingRepositoryMockDeleteParams {
- mmDelete.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockDeleteParams, 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 *ThingRepositoryMock) MinimockDeleteDone() bool {
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockDeleteInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockDeleteInspect() {
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
- if m.DeleteMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.Delete")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.Delete")
- }
- }
- type mThingRepositoryMockGet struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockGetExpectation
- expectations []*ThingRepositoryMockGetExpectation
- callArgs []*ThingRepositoryMockGetParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockGetExpectation specifies expectation struct of the ThingRepository.Get
- type ThingRepositoryMockGetExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockGetParams
- results *ThingRepositoryMockGetResults
- Counter uint64
- }
- // ThingRepositoryMockGetParams contains parameters of the ThingRepository.Get
- type ThingRepositoryMockGetParams struct {
- ctx context.Context
- thingID int
- }
- // ThingRepositoryMockGetResults contains results of the ThingRepository.Get
- type ThingRepositoryMockGetResults struct {
- tp1 *models.Thing
- err error
- }
- // Expect sets up expected params for ThingRepository.Get
- func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, thingID int) *mThingRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
- }
- mmGet.defaultExpectation.params = &ThingRepositoryMockGetParams{ctx, thingID}
- 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
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Get
- func (mmGet *mThingRepositoryMockGet) Inspect(f func(ctx context.Context, thingID int)) *mThingRepositoryMockGet {
- if mmGet.mock.inspectFuncGet != nil {
- mmGet.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Get")
- }
- mmGet.mock.inspectFuncGet = f
- return mmGet
- }
- // Return sets up results that will be returned by ThingRepository.Get
- func (mmGet *mThingRepositoryMockGet) Return(tp1 *models.Thing, err error) *ThingRepositoryMock {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{mock: mmGet.mock}
- }
- mmGet.defaultExpectation.results = &ThingRepositoryMockGetResults{tp1, err}
- return mmGet.mock
- }
- // Set uses given function f to mock the ThingRepository.Get method
- func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, thingID int) (tp1 *models.Thing, err error)) *ThingRepositoryMock {
- if mmGet.defaultExpectation != nil {
- mmGet.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Get method")
- }
- if len(mmGet.expectations) > 0 {
- mmGet.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Get method")
- }
- mmGet.mock.funcGet = f
- return mmGet.mock
- }
- // When sets expectation for the ThingRepository.Get which will trigger the result defined by the following
- // Then helper
- func (mmGet *mThingRepositoryMockGet) When(ctx context.Context, thingID int) *ThingRepositoryMockGetExpectation {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
- }
- expectation := &ThingRepositoryMockGetExpectation{
- mock: mmGet.mock,
- params: &ThingRepositoryMockGetParams{ctx, thingID},
- }
- mmGet.expectations = append(mmGet.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Get return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockGetExpectation) Then(tp1 *models.Thing, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockGetResults{tp1, err}
- return e.mock
- }
- // Get implements interfaces.ThingRepository
- func (mmGet *ThingRepositoryMock) Get(ctx context.Context, thingID int) (tp1 *models.Thing, err error) {
- mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
- defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
- if mmGet.inspectFuncGet != nil {
- mmGet.inspectFuncGet(ctx, thingID)
- }
- mm_params := &ThingRepositoryMockGetParams{ctx, thingID}
- // 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.tp1, e.results.err
- }
- }
- if mmGet.GetMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
- mm_want := mmGet.GetMock.defaultExpectation.params
- mm_got := ThingRepositoryMockGetParams{ctx, thingID}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGet.t.Errorf("ThingRepositoryMock.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 ThingRepositoryMock.Get")
- }
- return (*mm_results).tp1, (*mm_results).err
- }
- if mmGet.funcGet != nil {
- return mmGet.funcGet(ctx, thingID)
- }
- mmGet.t.Fatalf("Unexpected call to ThingRepositoryMock.Get. %v %v", ctx, thingID)
- return
- }
- // GetAfterCounter returns a count of finished ThingRepositoryMock.Get invocations
- func (mmGet *ThingRepositoryMock) GetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
- }
- // GetBeforeCounter returns a count of ThingRepositoryMock.Get invocations
- func (mmGet *ThingRepositoryMock) GetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Get.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGet *mThingRepositoryMockGet) Calls() []*ThingRepositoryMockGetParams {
- mmGet.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockGetParams, 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 *ThingRepositoryMock) MinimockGetDone() bool {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockGetInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockGetInspect() {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
- if m.GetMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.Get")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.Get")
- }
- }
- type mThingRepositoryMockGetAllByPlaceID struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockGetAllByPlaceIDExpectation
- expectations []*ThingRepositoryMockGetAllByPlaceIDExpectation
- callArgs []*ThingRepositoryMockGetAllByPlaceIDParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockGetAllByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetAllByPlaceID
- type ThingRepositoryMockGetAllByPlaceIDExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockGetAllByPlaceIDParams
- results *ThingRepositoryMockGetAllByPlaceIDResults
- Counter uint64
- }
- // ThingRepositoryMockGetAllByPlaceIDParams contains parameters of the ThingRepository.GetAllByPlaceID
- type ThingRepositoryMockGetAllByPlaceIDParams struct {
- ctx context.Context
- placeID int
- }
- // ThingRepositoryMockGetAllByPlaceIDResults contains results of the ThingRepository.GetAllByPlaceID
- type ThingRepositoryMockGetAllByPlaceIDResults struct {
- ta1 []models.Thing
- err error
- }
- // Expect sets up expected params for ThingRepository.GetAllByPlaceID
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetAllByPlaceID {
- if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
- }
- if mmGetAllByPlaceID.defaultExpectation == nil {
- mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
- }
- mmGetAllByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
- for _, e := range mmGetAllByPlaceID.expectations {
- if minimock.Equal(e.params, mmGetAllByPlaceID.defaultExpectation.params) {
- mmGetAllByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllByPlaceID.defaultExpectation.params)
- }
- }
- return mmGetAllByPlaceID
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetAllByPlaceID
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetAllByPlaceID {
- if mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetAllByPlaceID")
- }
- mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID = f
- return mmGetAllByPlaceID
- }
- // Return sets up results that will be returned by ThingRepository.GetAllByPlaceID
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
- if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
- }
- if mmGetAllByPlaceID.defaultExpectation == nil {
- mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{mock: mmGetAllByPlaceID.mock}
- }
- mmGetAllByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
- return mmGetAllByPlaceID.mock
- }
- // Set uses given function f to mock the ThingRepository.GetAllByPlaceID method
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
- if mmGetAllByPlaceID.defaultExpectation != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetAllByPlaceID method")
- }
- if len(mmGetAllByPlaceID.expectations) > 0 {
- mmGetAllByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetAllByPlaceID method")
- }
- mmGetAllByPlaceID.mock.funcGetAllByPlaceID = f
- return mmGetAllByPlaceID.mock
- }
- // When sets expectation for the ThingRepository.GetAllByPlaceID which will trigger the result defined by the following
- // Then helper
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetAllByPlaceIDExpectation {
- if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
- mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
- }
- expectation := &ThingRepositoryMockGetAllByPlaceIDExpectation{
- mock: mmGetAllByPlaceID.mock,
- params: &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID},
- }
- mmGetAllByPlaceID.expectations = append(mmGetAllByPlaceID.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.GetAllByPlaceID return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockGetAllByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
- return e.mock
- }
- // GetAllByPlaceID implements interfaces.ThingRepository
- func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
- mm_atomic.AddUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter, 1)
- defer mm_atomic.AddUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter, 1)
- if mmGetAllByPlaceID.inspectFuncGetAllByPlaceID != nil {
- mmGetAllByPlaceID.inspectFuncGetAllByPlaceID(ctx, placeID)
- }
- mm_params := &ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
- // Record call args
- mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Lock()
- mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs = append(mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs, mm_params)
- mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Unlock()
- for _, e := range mmGetAllByPlaceID.GetAllByPlaceIDMock.expectations {
- if minimock.Equal(e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ta1, e.results.err
- }
- }
- if mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.Counter, 1)
- mm_want := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.params
- mm_got := ThingRepositoryMockGetAllByPlaceIDParams{ctx, placeID}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.results
- if mm_results == nil {
- mmGetAllByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetAllByPlaceID")
- }
- return (*mm_results).ta1, (*mm_results).err
- }
- if mmGetAllByPlaceID.funcGetAllByPlaceID != nil {
- return mmGetAllByPlaceID.funcGetAllByPlaceID(ctx, placeID)
- }
- mmGetAllByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetAllByPlaceID. %v %v", ctx, placeID)
- return
- }
- // GetAllByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetAllByPlaceID invocations
- func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter)
- }
- // GetAllByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetAllByPlaceID invocations
- func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetAllByPlaceID.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Calls() []*ThingRepositoryMockGetAllByPlaceIDParams {
- mmGetAllByPlaceID.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockGetAllByPlaceIDParams, len(mmGetAllByPlaceID.callArgs))
- copy(argCopy, mmGetAllByPlaceID.callArgs)
- mmGetAllByPlaceID.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetAllByPlaceIDDone returns true if the count of the GetAllByPlaceID invocations corresponds
- // the number of defined expectations
- func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDDone() bool {
- for _, e := range m.GetAllByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.GetAllByPlaceIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetAllByPlaceID != nil && mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockGetAllByPlaceIDInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDInspect() {
- for _, e := range m.GetAllByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.GetAllByPlaceIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter) < 1 {
- if m.GetAllByPlaceIDMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *m.GetAllByPlaceIDMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetAllByPlaceID != nil && mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
- }
- }
- type mThingRepositoryMockGetByPlaceID struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockGetByPlaceIDExpectation
- expectations []*ThingRepositoryMockGetByPlaceIDExpectation
- callArgs []*ThingRepositoryMockGetByPlaceIDParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetByPlaceID
- type ThingRepositoryMockGetByPlaceIDExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockGetByPlaceIDParams
- results *ThingRepositoryMockGetByPlaceIDResults
- Counter uint64
- }
- // ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID
- type ThingRepositoryMockGetByPlaceIDParams struct {
- ctx context.Context
- placeID int
- }
- // ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID
- type ThingRepositoryMockGetByPlaceIDResults struct {
- ta1 []models.Thing
- err error
- }
- // Expect sets up expected params for ThingRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, placeID int) *mThingRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
- }
- mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
- 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
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, placeID int)) *mThingRepositoryMockGetByPlaceID {
- if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID")
- }
- mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f
- return mmGetByPlaceID
- }
- // Return sets up results that will be returned by ThingRepository.GetByPlaceID
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- if mmGetByPlaceID.defaultExpectation == nil {
- mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
- }
- mmGetByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
- return mmGetByPlaceID.mock
- }
- // Set uses given function f to mock the ThingRepository.GetByPlaceID method
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, placeID int) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
- if mmGetByPlaceID.defaultExpectation != nil {
- mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method")
- }
- if len(mmGetByPlaceID.expectations) > 0 {
- mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetByPlaceID method")
- }
- mmGetByPlaceID.mock.funcGetByPlaceID = f
- return mmGetByPlaceID.mock
- }
- // When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following
- // Then helper
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, placeID int) *ThingRepositoryMockGetByPlaceIDExpectation {
- if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
- mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
- }
- expectation := &ThingRepositoryMockGetByPlaceIDExpectation{
- mock: mmGetByPlaceID.mock,
- params: &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID},
- }
- mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockGetByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
- return e.mock
- }
- // GetByPlaceID implements interfaces.ThingRepository
- func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, placeID int) (ta1 []models.Thing, err error) {
- mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
- defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)
- if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
- mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, placeID)
- }
- mm_params := &ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
- // 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.ta1, e.results.err
- }
- }
- if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
- mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
- mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, placeID}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGetByPlaceID.t.Errorf("ThingRepositoryMock.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 ThingRepositoryMock.GetByPlaceID")
- }
- return (*mm_results).ta1, (*mm_results).err
- }
- if mmGetByPlaceID.funcGetByPlaceID != nil {
- return mmGetByPlaceID.funcGetByPlaceID(ctx, placeID)
- }
- mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, placeID)
- return
- }
- // GetByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetByPlaceID invocations
- func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
- }
- // GetByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetByPlaceID invocations
- func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.GetByPlaceID.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Calls() []*ThingRepositoryMockGetByPlaceIDParams {
- mmGetByPlaceID.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockGetByPlaceIDParams, 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 *ThingRepositoryMock) MinimockGetByPlaceIDDone() bool {
- for _, e := range m.GetByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.GetByPlaceIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetByPlaceID != nil && mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockGetByPlaceIDInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockGetByPlaceIDInspect() {
- for _, e := range m.GetByPlaceIDMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.GetByPlaceIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) < 1 {
- if m.GetByPlaceIDMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetByPlaceID != nil && mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
- }
- }
- type mThingRepositoryMockSearch struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockSearchExpectation
- expectations []*ThingRepositoryMockSearchExpectation
- callArgs []*ThingRepositoryMockSearchParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockSearchExpectation specifies expectation struct of the ThingRepository.Search
- type ThingRepositoryMockSearchExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockSearchParams
- results *ThingRepositoryMockSearchResults
- Counter uint64
- }
- // ThingRepositoryMockSearchParams contains parameters of the ThingRepository.Search
- type ThingRepositoryMockSearchParams struct {
- ctx context.Context
- search string
- }
- // ThingRepositoryMockSearchResults contains results of the ThingRepository.Search
- type ThingRepositoryMockSearchResults struct {
- ta1 []models.Thing
- err error
- }
- // Expect sets up expected params for ThingRepository.Search
- func (mmSearch *mThingRepositoryMockSearch) Expect(ctx context.Context, search string) *mThingRepositoryMockSearch {
- if mmSearch.mock.funcSearch != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
- }
- if mmSearch.defaultExpectation == nil {
- mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
- }
- mmSearch.defaultExpectation.params = &ThingRepositoryMockSearchParams{ctx, search}
- for _, e := range mmSearch.expectations {
- if minimock.Equal(e.params, mmSearch.defaultExpectation.params) {
- mmSearch.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSearch.defaultExpectation.params)
- }
- }
- return mmSearch
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Search
- func (mmSearch *mThingRepositoryMockSearch) Inspect(f func(ctx context.Context, search string)) *mThingRepositoryMockSearch {
- if mmSearch.mock.inspectFuncSearch != nil {
- mmSearch.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Search")
- }
- mmSearch.mock.inspectFuncSearch = f
- return mmSearch
- }
- // Return sets up results that will be returned by ThingRepository.Search
- func (mmSearch *mThingRepositoryMockSearch) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
- if mmSearch.mock.funcSearch != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
- }
- if mmSearch.defaultExpectation == nil {
- mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{mock: mmSearch.mock}
- }
- mmSearch.defaultExpectation.results = &ThingRepositoryMockSearchResults{ta1, err}
- return mmSearch.mock
- }
- // Set uses given function f to mock the ThingRepository.Search method
- func (mmSearch *mThingRepositoryMockSearch) Set(f func(ctx context.Context, search string) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
- if mmSearch.defaultExpectation != nil {
- mmSearch.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Search method")
- }
- if len(mmSearch.expectations) > 0 {
- mmSearch.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Search method")
- }
- mmSearch.mock.funcSearch = f
- return mmSearch.mock
- }
- // When sets expectation for the ThingRepository.Search which will trigger the result defined by the following
- // Then helper
- func (mmSearch *mThingRepositoryMockSearch) When(ctx context.Context, search string) *ThingRepositoryMockSearchExpectation {
- if mmSearch.mock.funcSearch != nil {
- mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
- }
- expectation := &ThingRepositoryMockSearchExpectation{
- mock: mmSearch.mock,
- params: &ThingRepositoryMockSearchParams{ctx, search},
- }
- mmSearch.expectations = append(mmSearch.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Search return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockSearchExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockSearchResults{ta1, err}
- return e.mock
- }
- // Search implements interfaces.ThingRepository
- func (mmSearch *ThingRepositoryMock) Search(ctx context.Context, search string) (ta1 []models.Thing, err error) {
- mm_atomic.AddUint64(&mmSearch.beforeSearchCounter, 1)
- defer mm_atomic.AddUint64(&mmSearch.afterSearchCounter, 1)
- if mmSearch.inspectFuncSearch != nil {
- mmSearch.inspectFuncSearch(ctx, search)
- }
- mm_params := &ThingRepositoryMockSearchParams{ctx, search}
- // Record call args
- mmSearch.SearchMock.mutex.Lock()
- mmSearch.SearchMock.callArgs = append(mmSearch.SearchMock.callArgs, mm_params)
- mmSearch.SearchMock.mutex.Unlock()
- for _, e := range mmSearch.SearchMock.expectations {
- if minimock.Equal(e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ta1, e.results.err
- }
- }
- if mmSearch.SearchMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmSearch.SearchMock.defaultExpectation.Counter, 1)
- mm_want := mmSearch.SearchMock.defaultExpectation.params
- mm_got := ThingRepositoryMockSearchParams{ctx, search}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmSearch.SearchMock.defaultExpectation.results
- if mm_results == nil {
- mmSearch.t.Fatal("No results are set for the ThingRepositoryMock.Search")
- }
- return (*mm_results).ta1, (*mm_results).err
- }
- if mmSearch.funcSearch != nil {
- return mmSearch.funcSearch(ctx, search)
- }
- mmSearch.t.Fatalf("Unexpected call to ThingRepositoryMock.Search. %v %v", ctx, search)
- return
- }
- // SearchAfterCounter returns a count of finished ThingRepositoryMock.Search invocations
- func (mmSearch *ThingRepositoryMock) SearchAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmSearch.afterSearchCounter)
- }
- // SearchBeforeCounter returns a count of ThingRepositoryMock.Search invocations
- func (mmSearch *ThingRepositoryMock) SearchBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmSearch.beforeSearchCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Search.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmSearch *mThingRepositoryMockSearch) Calls() []*ThingRepositoryMockSearchParams {
- mmSearch.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockSearchParams, len(mmSearch.callArgs))
- copy(argCopy, mmSearch.callArgs)
- mmSearch.mutex.RUnlock()
- return argCopy
- }
- // MinimockSearchDone returns true if the count of the Search invocations corresponds
- // the number of defined expectations
- func (m *ThingRepositoryMock) MinimockSearchDone() bool {
- for _, e := range m.SearchMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.SearchMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSearchCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcSearch != nil && mm_atomic.LoadUint64(&m.afterSearchCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockSearchInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockSearchInspect() {
- for _, e := range m.SearchMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.SearchMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSearchCounter) < 1 {
- if m.SearchMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.Search")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *m.SearchMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcSearch != nil && mm_atomic.LoadUint64(&m.afterSearchCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.Search")
- }
- }
- type mThingRepositoryMockUpdate struct {
- mock *ThingRepositoryMock
- defaultExpectation *ThingRepositoryMockUpdateExpectation
- expectations []*ThingRepositoryMockUpdateExpectation
- callArgs []*ThingRepositoryMockUpdateParams
- mutex sync.RWMutex
- }
- // ThingRepositoryMockUpdateExpectation specifies expectation struct of the ThingRepository.Update
- type ThingRepositoryMockUpdateExpectation struct {
- mock *ThingRepositoryMock
- params *ThingRepositoryMockUpdateParams
- results *ThingRepositoryMockUpdateResults
- Counter uint64
- }
- // ThingRepositoryMockUpdateParams contains parameters of the ThingRepository.Update
- type ThingRepositoryMockUpdateParams struct {
- ctx context.Context
- req models.UpdateThingRequest
- tx *sql.Tx
- }
- // ThingRepositoryMockUpdateResults contains results of the ThingRepository.Update
- type ThingRepositoryMockUpdateResults struct {
- err error
- }
- // Expect sets up expected params for ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) *mThingRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
- }
- mmUpdate.defaultExpectation.params = &ThingRepositoryMockUpdateParams{ctx, req, tx}
- for _, e := range mmUpdate.expectations {
- if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
- mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
- }
- }
- return mmUpdate
- }
- // Inspect accepts an inspector function that has same arguments as the ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx)) *mThingRepositoryMockUpdate {
- if mmUpdate.mock.inspectFuncUpdate != nil {
- mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Update")
- }
- mmUpdate.mock.inspectFuncUpdate = f
- return mmUpdate
- }
- // Return sets up results that will be returned by ThingRepository.Update
- func (mmUpdate *mThingRepositoryMockUpdate) Return(err error) *ThingRepositoryMock {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
- }
- mmUpdate.defaultExpectation.results = &ThingRepositoryMockUpdateResults{err}
- return mmUpdate.mock
- }
- // Set uses given function f to mock the ThingRepository.Update method
- func (mmUpdate *mThingRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error)) *ThingRepositoryMock {
- if mmUpdate.defaultExpectation != nil {
- mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Update method")
- }
- if len(mmUpdate.expectations) > 0 {
- mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Update method")
- }
- mmUpdate.mock.funcUpdate = f
- return mmUpdate.mock
- }
- // When sets expectation for the ThingRepository.Update which will trigger the result defined by the following
- // Then helper
- func (mmUpdate *mThingRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) *ThingRepositoryMockUpdateExpectation {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
- }
- expectation := &ThingRepositoryMockUpdateExpectation{
- mock: mmUpdate.mock,
- params: &ThingRepositoryMockUpdateParams{ctx, req, tx},
- }
- mmUpdate.expectations = append(mmUpdate.expectations, expectation)
- return expectation
- }
- // Then sets up ThingRepository.Update return parameters for the expectation previously defined by the When method
- func (e *ThingRepositoryMockUpdateExpectation) Then(err error) *ThingRepositoryMock {
- e.results = &ThingRepositoryMockUpdateResults{err}
- return e.mock
- }
- // Update implements interfaces.ThingRepository
- func (mmUpdate *ThingRepositoryMock) Update(ctx context.Context, req models.UpdateThingRequest, tx *sql.Tx) (err error) {
- mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
- defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
- if mmUpdate.inspectFuncUpdate != nil {
- mmUpdate.inspectFuncUpdate(ctx, req, tx)
- }
- mm_params := &ThingRepositoryMockUpdateParams{ctx, req, tx}
- // Record call args
- mmUpdate.UpdateMock.mutex.Lock()
- mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, mm_params)
- mmUpdate.UpdateMock.mutex.Unlock()
- for _, e := range mmUpdate.UpdateMock.expectations {
- if minimock.Equal(e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.err
- }
- }
- if mmUpdate.UpdateMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
- mm_want := mmUpdate.UpdateMock.defaultExpectation.params
- mm_got := ThingRepositoryMockUpdateParams{ctx, req, tx}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmUpdate.t.Errorf("ThingRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmUpdate.UpdateMock.defaultExpectation.results
- if mm_results == nil {
- mmUpdate.t.Fatal("No results are set for the ThingRepositoryMock.Update")
- }
- return (*mm_results).err
- }
- if mmUpdate.funcUpdate != nil {
- return mmUpdate.funcUpdate(ctx, req, tx)
- }
- mmUpdate.t.Fatalf("Unexpected call to ThingRepositoryMock.Update. %v %v %v", ctx, req, tx)
- return
- }
- // UpdateAfterCounter returns a count of finished ThingRepositoryMock.Update invocations
- func (mmUpdate *ThingRepositoryMock) UpdateAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
- }
- // UpdateBeforeCounter returns a count of ThingRepositoryMock.Update invocations
- func (mmUpdate *ThingRepositoryMock) UpdateBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
- }
- // Calls returns a list of arguments used in each call to ThingRepositoryMock.Update.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmUpdate *mThingRepositoryMockUpdate) Calls() []*ThingRepositoryMockUpdateParams {
- mmUpdate.mutex.RLock()
- argCopy := make([]*ThingRepositoryMockUpdateParams, len(mmUpdate.callArgs))
- copy(argCopy, mmUpdate.callArgs)
- mmUpdate.mutex.RUnlock()
- return argCopy
- }
- // MinimockUpdateDone returns true if the count of the Update invocations corresponds
- // the number of defined expectations
- func (m *ThingRepositoryMock) MinimockUpdateDone() bool {
- for _, e := range m.UpdateMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
- return false
- }
- // if func was set then invocations count should be greater than zero
- if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
- return false
- }
- return true
- }
- // MinimockUpdateInspect logs each unmet expectation
- func (m *ThingRepositoryMock) MinimockUpdateInspect() {
- for _, e := range m.UpdateMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *e.params)
- }
- }
- // if default expectation was set then invocations count should be greater than zero
- if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
- if m.UpdateMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingRepositoryMock.Update")
- } else {
- m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
- m.t.Error("Expected call to ThingRepositoryMock.Update")
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *ThingRepositoryMock) MinimockFinish() {
- if !m.minimockDone() {
- m.MinimockAddInspect()
- m.MinimockBeginTxInspect()
- m.MinimockCommitTxInspect()
- m.MinimockDeleteInspect()
- m.MinimockGetInspect()
- m.MinimockGetAllByPlaceIDInspect()
- m.MinimockGetByPlaceIDInspect()
- m.MinimockSearchInspect()
- m.MinimockUpdateInspect()
- m.t.FailNow()
- }
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *ThingRepositoryMock) 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 *ThingRepositoryMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockAddDone() &&
- m.MinimockBeginTxDone() &&
- m.MinimockCommitTxDone() &&
- m.MinimockDeleteDone() &&
- m.MinimockGetDone() &&
- m.MinimockGetAllByPlaceIDDone() &&
- m.MinimockGetByPlaceIDDone() &&
- m.MinimockSearchDone() &&
- m.MinimockUpdateDone()
- }
|