1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696 |
- // 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/notification.ThingNotificationRepository -o thing_notification_repository_minimock.go -n ThingNotificationRepositoryMock -p mocks
- import (
- "context"
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "git.dmitriygnatenko.ru/dima/homethings/internal/models"
- "github.com/gojuno/minimock/v3"
- )
- // ThingNotificationRepositoryMock implements notification.ThingNotificationRepository
- type ThingNotificationRepositoryMock struct {
- t minimock.Tester
- finishOnce sync.Once
- funcAdd func(ctx context.Context, req models.AddThingNotificationRequest) (err error)
- inspectFuncAdd func(ctx context.Context, req models.AddThingNotificationRequest)
- afterAddCounter uint64
- beforeAddCounter uint64
- AddMock mThingNotificationRepositoryMockAdd
- funcDelete func(ctx context.Context, id uint64) (err error)
- inspectFuncDelete func(ctx context.Context, id uint64)
- afterDeleteCounter uint64
- beforeDeleteCounter uint64
- DeleteMock mThingNotificationRepositoryMockDelete
- funcGet func(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error)
- inspectFuncGet func(ctx context.Context, id uint64)
- afterGetCounter uint64
- beforeGetCounter uint64
- GetMock mThingNotificationRepositoryMockGet
- funcGetExpired func(ctx context.Context) (ea1 []models.ExtThingNotification, err error)
- inspectFuncGetExpired func(ctx context.Context)
- afterGetExpiredCounter uint64
- beforeGetExpiredCounter uint64
- GetExpiredMock mThingNotificationRepositoryMockGetExpired
- funcUpdate func(ctx context.Context, req models.UpdateThingNotificationRequest) (err error)
- inspectFuncUpdate func(ctx context.Context, req models.UpdateThingNotificationRequest)
- afterUpdateCounter uint64
- beforeUpdateCounter uint64
- UpdateMock mThingNotificationRepositoryMockUpdate
- }
- // NewThingNotificationRepositoryMock returns a mock for notification.ThingNotificationRepository
- func NewThingNotificationRepositoryMock(t minimock.Tester) *ThingNotificationRepositoryMock {
- m := &ThingNotificationRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.AddMock = mThingNotificationRepositoryMockAdd{mock: m}
- m.AddMock.callArgs = []*ThingNotificationRepositoryMockAddParams{}
- m.DeleteMock = mThingNotificationRepositoryMockDelete{mock: m}
- m.DeleteMock.callArgs = []*ThingNotificationRepositoryMockDeleteParams{}
- m.GetMock = mThingNotificationRepositoryMockGet{mock: m}
- m.GetMock.callArgs = []*ThingNotificationRepositoryMockGetParams{}
- m.GetExpiredMock = mThingNotificationRepositoryMockGetExpired{mock: m}
- m.GetExpiredMock.callArgs = []*ThingNotificationRepositoryMockGetExpiredParams{}
- m.UpdateMock = mThingNotificationRepositoryMockUpdate{mock: m}
- m.UpdateMock.callArgs = []*ThingNotificationRepositoryMockUpdateParams{}
- t.Cleanup(m.MinimockFinish)
- return m
- }
- type mThingNotificationRepositoryMockAdd struct {
- optional bool
- mock *ThingNotificationRepositoryMock
- defaultExpectation *ThingNotificationRepositoryMockAddExpectation
- expectations []*ThingNotificationRepositoryMockAddExpectation
- callArgs []*ThingNotificationRepositoryMockAddParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingNotificationRepositoryMockAddExpectation specifies expectation struct of the ThingNotificationRepository.Add
- type ThingNotificationRepositoryMockAddExpectation struct {
- mock *ThingNotificationRepositoryMock
- params *ThingNotificationRepositoryMockAddParams
- paramPtrs *ThingNotificationRepositoryMockAddParamPtrs
- results *ThingNotificationRepositoryMockAddResults
- Counter uint64
- }
- // ThingNotificationRepositoryMockAddParams contains parameters of the ThingNotificationRepository.Add
- type ThingNotificationRepositoryMockAddParams struct {
- ctx context.Context
- req models.AddThingNotificationRequest
- }
- // ThingNotificationRepositoryMockAddParamPtrs contains pointers to parameters of the ThingNotificationRepository.Add
- type ThingNotificationRepositoryMockAddParamPtrs struct {
- ctx *context.Context
- req *models.AddThingNotificationRequest
- }
- // ThingNotificationRepositoryMockAddResults contains results of the ThingNotificationRepository.Add
- type ThingNotificationRepositoryMockAddResults 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 *mThingNotificationRepositoryMockAdd) Optional() *mThingNotificationRepositoryMockAdd {
- mmAdd.optional = true
- return mmAdd
- }
- // Expect sets up expected params for ThingNotificationRepository.Add
- func (mmAdd *mThingNotificationRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingNotificationRequest) *mThingNotificationRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.paramPtrs != nil {
- mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by ExpectParams functions")
- }
- mmAdd.defaultExpectation.params = &ThingNotificationRepositoryMockAddParams{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 ThingNotificationRepository.Add
- func (mmAdd *mThingNotificationRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.ctx = &ctx
- return mmAdd
- }
- // ExpectReqParam2 sets up expected param req for ThingNotificationRepository.Add
- func (mmAdd *mThingNotificationRepositoryMockAdd) ExpectReqParam2(req models.AddThingNotificationRequest) *mThingNotificationRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{}
- }
- if mmAdd.defaultExpectation.params != nil {
- mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Expect")
- }
- if mmAdd.defaultExpectation.paramPtrs == nil {
- mmAdd.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockAddParamPtrs{}
- }
- mmAdd.defaultExpectation.paramPtrs.req = &req
- return mmAdd
- }
- // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Add
- func (mmAdd *mThingNotificationRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingNotificationRequest)) *mThingNotificationRepositoryMockAdd {
- if mmAdd.mock.inspectFuncAdd != nil {
- mmAdd.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Add")
- }
- mmAdd.mock.inspectFuncAdd = f
- return mmAdd
- }
- // Return sets up results that will be returned by ThingNotificationRepository.Add
- func (mmAdd *mThingNotificationRepositoryMockAdd) Return(err error) *ThingNotificationRepositoryMock {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &ThingNotificationRepositoryMockAddExpectation{mock: mmAdd.mock}
- }
- mmAdd.defaultExpectation.results = &ThingNotificationRepositoryMockAddResults{err}
- return mmAdd.mock
- }
- // Set uses given function f to mock the ThingNotificationRepository.Add method
- func (mmAdd *mThingNotificationRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingNotificationRequest) (err error)) *ThingNotificationRepositoryMock {
- if mmAdd.defaultExpectation != nil {
- mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Add method")
- }
- if len(mmAdd.expectations) > 0 {
- mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Add method")
- }
- mmAdd.mock.funcAdd = f
- return mmAdd.mock
- }
- // When sets expectation for the ThingNotificationRepository.Add which will trigger the result defined by the following
- // Then helper
- func (mmAdd *mThingNotificationRepositoryMockAdd) When(ctx context.Context, req models.AddThingNotificationRequest) *ThingNotificationRepositoryMockAddExpectation {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("ThingNotificationRepositoryMock.Add mock is already set by Set")
- }
- expectation := &ThingNotificationRepositoryMockAddExpectation{
- mock: mmAdd.mock,
- params: &ThingNotificationRepositoryMockAddParams{ctx, req},
- }
- mmAdd.expectations = append(mmAdd.expectations, expectation)
- return expectation
- }
- // Then sets up ThingNotificationRepository.Add return parameters for the expectation previously defined by the When method
- func (e *ThingNotificationRepositoryMockAddExpectation) Then(err error) *ThingNotificationRepositoryMock {
- e.results = &ThingNotificationRepositoryMockAddResults{err}
- return e.mock
- }
- // Times sets number of times ThingNotificationRepository.Add should be invoked
- func (mmAdd *mThingNotificationRepositoryMockAdd) Times(n uint64) *mThingNotificationRepositoryMockAdd {
- if n == 0 {
- mmAdd.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Add mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
- return mmAdd
- }
- func (mmAdd *mThingNotificationRepositoryMockAdd) 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 notification.ThingNotificationRepository
- func (mmAdd *ThingNotificationRepositoryMock) Add(ctx context.Context, req models.AddThingNotificationRequest) (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 := ThingNotificationRepositoryMockAddParams{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 := ThingNotificationRepositoryMockAddParams{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("ThingNotificationRepositoryMock.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("ThingNotificationRepositoryMock.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("ThingNotificationRepositoryMock.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 ThingNotificationRepositoryMock.Add")
- }
- return (*mm_results).err
- }
- if mmAdd.funcAdd != nil {
- return mmAdd.funcAdd(ctx, req)
- }
- mmAdd.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Add. %v %v", ctx, req)
- return
- }
- // AddAfterCounter returns a count of finished ThingNotificationRepositoryMock.Add invocations
- func (mmAdd *ThingNotificationRepositoryMock) AddAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
- }
- // AddBeforeCounter returns a count of ThingNotificationRepositoryMock.Add invocations
- func (mmAdd *ThingNotificationRepositoryMock) AddBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
- }
- // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Add.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmAdd *mThingNotificationRepositoryMockAdd) Calls() []*ThingNotificationRepositoryMockAddParams {
- mmAdd.mutex.RLock()
- argCopy := make([]*ThingNotificationRepositoryMockAddParams, 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 *ThingNotificationRepositoryMock) 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 *ThingNotificationRepositoryMock) MinimockAddInspect() {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.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 ThingNotificationRepositoryMock.Add")
- } else {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.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 ThingNotificationRepositoryMock.Add")
- }
- if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Add but found %d calls",
- mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
- }
- }
- type mThingNotificationRepositoryMockDelete struct {
- optional bool
- mock *ThingNotificationRepositoryMock
- defaultExpectation *ThingNotificationRepositoryMockDeleteExpectation
- expectations []*ThingNotificationRepositoryMockDeleteExpectation
- callArgs []*ThingNotificationRepositoryMockDeleteParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingNotificationRepositoryMockDeleteExpectation specifies expectation struct of the ThingNotificationRepository.Delete
- type ThingNotificationRepositoryMockDeleteExpectation struct {
- mock *ThingNotificationRepositoryMock
- params *ThingNotificationRepositoryMockDeleteParams
- paramPtrs *ThingNotificationRepositoryMockDeleteParamPtrs
- results *ThingNotificationRepositoryMockDeleteResults
- Counter uint64
- }
- // ThingNotificationRepositoryMockDeleteParams contains parameters of the ThingNotificationRepository.Delete
- type ThingNotificationRepositoryMockDeleteParams struct {
- ctx context.Context
- id uint64
- }
- // ThingNotificationRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingNotificationRepository.Delete
- type ThingNotificationRepositoryMockDeleteParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // ThingNotificationRepositoryMockDeleteResults contains results of the ThingNotificationRepository.Delete
- type ThingNotificationRepositoryMockDeleteResults struct {
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmDelete *mThingNotificationRepositoryMockDelete) Optional() *mThingNotificationRepositoryMockDelete {
- mmDelete.optional = true
- return mmDelete
- }
- // Expect sets up expected params for ThingNotificationRepository.Delete
- func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.paramPtrs != nil {
- mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by ExpectParams functions")
- }
- mmDelete.defaultExpectation.params = &ThingNotificationRepositoryMockDeleteParams{ctx, id}
- for _, e := range mmDelete.expectations {
- if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
- mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
- }
- }
- return mmDelete
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.Delete
- func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.ctx = &ctx
- return mmDelete
- }
- // ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Delete
- func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockDelete {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
- }
- if mmDelete.defaultExpectation.params != nil {
- mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
- }
- if mmDelete.defaultExpectation.paramPtrs == nil {
- mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
- }
- mmDelete.defaultExpectation.paramPtrs.id = &id
- return mmDelete
- }
- // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Delete
- func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockDelete {
- if mmDelete.mock.inspectFuncDelete != nil {
- mmDelete.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Delete")
- }
- mmDelete.mock.inspectFuncDelete = f
- return mmDelete
- }
- // Return sets up results that will be returned by ThingNotificationRepository.Delete
- func (mmDelete *mThingNotificationRepositoryMockDelete) Return(err error) *ThingNotificationRepositoryMock {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
- }
- if mmDelete.defaultExpectation == nil {
- mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{mock: mmDelete.mock}
- }
- mmDelete.defaultExpectation.results = &ThingNotificationRepositoryMockDeleteResults{err}
- return mmDelete.mock
- }
- // Set uses given function f to mock the ThingNotificationRepository.Delete method
- func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingNotificationRepositoryMock {
- if mmDelete.defaultExpectation != nil {
- mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Delete method")
- }
- if len(mmDelete.expectations) > 0 {
- mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Delete method")
- }
- mmDelete.mock.funcDelete = f
- return mmDelete.mock
- }
- // When sets expectation for the ThingNotificationRepository.Delete which will trigger the result defined by the following
- // Then helper
- func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockDeleteExpectation {
- if mmDelete.mock.funcDelete != nil {
- mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
- }
- expectation := &ThingNotificationRepositoryMockDeleteExpectation{
- mock: mmDelete.mock,
- params: &ThingNotificationRepositoryMockDeleteParams{ctx, id},
- }
- mmDelete.expectations = append(mmDelete.expectations, expectation)
- return expectation
- }
- // Then sets up ThingNotificationRepository.Delete return parameters for the expectation previously defined by the When method
- func (e *ThingNotificationRepositoryMockDeleteExpectation) Then(err error) *ThingNotificationRepositoryMock {
- e.results = &ThingNotificationRepositoryMockDeleteResults{err}
- return e.mock
- }
- // Times sets number of times ThingNotificationRepository.Delete should be invoked
- func (mmDelete *mThingNotificationRepositoryMockDelete) Times(n uint64) *mThingNotificationRepositoryMockDelete {
- if n == 0 {
- mmDelete.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Delete mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
- return mmDelete
- }
- func (mmDelete *mThingNotificationRepositoryMockDelete) invocationsDone() bool {
- if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Delete implements notification.ThingNotificationRepository
- func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
- mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
- defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
- if mmDelete.inspectFuncDelete != nil {
- mmDelete.inspectFuncDelete(ctx, id)
- }
- mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, id}
- // Record call args
- mmDelete.DeleteMock.mutex.Lock()
- mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params)
- mmDelete.DeleteMock.mutex.Unlock()
- for _, e := range mmDelete.DeleteMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.err
- }
- }
- if mmDelete.DeleteMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
- mm_want := mmDelete.DeleteMock.defaultExpectation.params
- mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs
- mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, id}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
- mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmDelete.t.Errorf("ThingNotificationRepositoryMock.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 ThingNotificationRepositoryMock.Delete")
- }
- return (*mm_results).err
- }
- if mmDelete.funcDelete != nil {
- return mmDelete.funcDelete(ctx, id)
- }
- mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v", ctx, id)
- return
- }
- // DeleteAfterCounter returns a count of finished ThingNotificationRepositoryMock.Delete invocations
- func (mmDelete *ThingNotificationRepositoryMock) DeleteAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
- }
- // DeleteBeforeCounter returns a count of ThingNotificationRepositoryMock.Delete invocations
- func (mmDelete *ThingNotificationRepositoryMock) DeleteBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
- }
- // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Delete.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmDelete *mThingNotificationRepositoryMockDelete) Calls() []*ThingNotificationRepositoryMockDeleteParams {
- mmDelete.mutex.RLock()
- argCopy := make([]*ThingNotificationRepositoryMockDeleteParams, 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 *ThingNotificationRepositoryMock) MinimockDeleteDone() bool {
- if m.DeleteMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.DeleteMock.invocationsDone()
- }
- // MinimockDeleteInspect logs each unmet expectation
- func (m *ThingNotificationRepositoryMock) MinimockDeleteInspect() {
- for _, e := range m.DeleteMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Delete with params: %#v", *e.params)
- }
- }
- afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
- if m.DeleteMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingNotificationRepositoryMock.Delete")
- } else {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcDelete != nil && afterDeleteCounter < 1 {
- m.t.Error("Expected call to ThingNotificationRepositoryMock.Delete")
- }
- if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Delete but found %d calls",
- mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
- }
- }
- type mThingNotificationRepositoryMockGet struct {
- optional bool
- mock *ThingNotificationRepositoryMock
- defaultExpectation *ThingNotificationRepositoryMockGetExpectation
- expectations []*ThingNotificationRepositoryMockGetExpectation
- callArgs []*ThingNotificationRepositoryMockGetParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingNotificationRepositoryMockGetExpectation specifies expectation struct of the ThingNotificationRepository.Get
- type ThingNotificationRepositoryMockGetExpectation struct {
- mock *ThingNotificationRepositoryMock
- params *ThingNotificationRepositoryMockGetParams
- paramPtrs *ThingNotificationRepositoryMockGetParamPtrs
- results *ThingNotificationRepositoryMockGetResults
- Counter uint64
- }
- // ThingNotificationRepositoryMockGetParams contains parameters of the ThingNotificationRepository.Get
- type ThingNotificationRepositoryMockGetParams struct {
- ctx context.Context
- id uint64
- }
- // ThingNotificationRepositoryMockGetParamPtrs contains pointers to parameters of the ThingNotificationRepository.Get
- type ThingNotificationRepositoryMockGetParamPtrs struct {
- ctx *context.Context
- id *uint64
- }
- // ThingNotificationRepositoryMockGetResults contains results of the ThingNotificationRepository.Get
- type ThingNotificationRepositoryMockGetResults struct {
- tp1 *models.ThingNotification
- err error
- }
- // Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
- // the test will fail minimock's automatic final call check if the mocked method was not called at least once.
- // Optional() makes method check to work in '0 or more' mode.
- // It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
- // catch the problems when the expected method call is totally skipped during test run.
- func (mmGet *mThingNotificationRepositoryMockGet) Optional() *mThingNotificationRepositoryMockGet {
- mmGet.optional = true
- return mmGet
- }
- // Expect sets up expected params for ThingNotificationRepository.Get
- func (mmGet *mThingNotificationRepositoryMockGet) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.paramPtrs != nil {
- mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by ExpectParams functions")
- }
- mmGet.defaultExpectation.params = &ThingNotificationRepositoryMockGetParams{ctx, id}
- for _, e := range mmGet.expectations {
- if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
- mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
- }
- }
- return mmGet
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.Get
- func (mmGet *mThingNotificationRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGet
- }
- // ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Get
- func (mmGet *mThingNotificationRepositoryMockGet) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{}
- }
- if mmGet.defaultExpectation.params != nil {
- mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Expect")
- }
- if mmGet.defaultExpectation.paramPtrs == nil {
- mmGet.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockGetParamPtrs{}
- }
- mmGet.defaultExpectation.paramPtrs.id = &id
- return mmGet
- }
- // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Get
- func (mmGet *mThingNotificationRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockGet {
- if mmGet.mock.inspectFuncGet != nil {
- mmGet.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Get")
- }
- mmGet.mock.inspectFuncGet = f
- return mmGet
- }
- // Return sets up results that will be returned by ThingNotificationRepository.Get
- func (mmGet *mThingNotificationRepositoryMockGet) Return(tp1 *models.ThingNotification, err error) *ThingNotificationRepositoryMock {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &ThingNotificationRepositoryMockGetExpectation{mock: mmGet.mock}
- }
- mmGet.defaultExpectation.results = &ThingNotificationRepositoryMockGetResults{tp1, err}
- return mmGet.mock
- }
- // Set uses given function f to mock the ThingNotificationRepository.Get method
- func (mmGet *mThingNotificationRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error)) *ThingNotificationRepositoryMock {
- if mmGet.defaultExpectation != nil {
- mmGet.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Get method")
- }
- if len(mmGet.expectations) > 0 {
- mmGet.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Get method")
- }
- mmGet.mock.funcGet = f
- return mmGet.mock
- }
- // When sets expectation for the ThingNotificationRepository.Get which will trigger the result defined by the following
- // Then helper
- func (mmGet *mThingNotificationRepositoryMockGet) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockGetExpectation {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("ThingNotificationRepositoryMock.Get mock is already set by Set")
- }
- expectation := &ThingNotificationRepositoryMockGetExpectation{
- mock: mmGet.mock,
- params: &ThingNotificationRepositoryMockGetParams{ctx, id},
- }
- mmGet.expectations = append(mmGet.expectations, expectation)
- return expectation
- }
- // Then sets up ThingNotificationRepository.Get return parameters for the expectation previously defined by the When method
- func (e *ThingNotificationRepositoryMockGetExpectation) Then(tp1 *models.ThingNotification, err error) *ThingNotificationRepositoryMock {
- e.results = &ThingNotificationRepositoryMockGetResults{tp1, err}
- return e.mock
- }
- // Times sets number of times ThingNotificationRepository.Get should be invoked
- func (mmGet *mThingNotificationRepositoryMockGet) Times(n uint64) *mThingNotificationRepositoryMockGet {
- if n == 0 {
- mmGet.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Get mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
- return mmGet
- }
- func (mmGet *mThingNotificationRepositoryMockGet) invocationsDone() bool {
- if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Get implements notification.ThingNotificationRepository
- func (mmGet *ThingNotificationRepositoryMock) Get(ctx context.Context, id uint64) (tp1 *models.ThingNotification, err error) {
- mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
- defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
- if mmGet.inspectFuncGet != nil {
- mmGet.inspectFuncGet(ctx, id)
- }
- mm_params := ThingNotificationRepositoryMockGetParams{ctx, id}
- // Record call args
- mmGet.GetMock.mutex.Lock()
- mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
- mmGet.GetMock.mutex.Unlock()
- for _, e := range mmGet.GetMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.tp1, e.results.err
- }
- }
- if mmGet.GetMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
- mm_want := mmGet.GetMock.defaultExpectation.params
- mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
- mm_got := ThingNotificationRepositoryMockGetParams{ctx, id}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
- }
- if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
- mmGet.t.Errorf("ThingNotificationRepositoryMock.Get got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGet.t.Errorf("ThingNotificationRepositoryMock.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 ThingNotificationRepositoryMock.Get")
- }
- return (*mm_results).tp1, (*mm_results).err
- }
- if mmGet.funcGet != nil {
- return mmGet.funcGet(ctx, id)
- }
- mmGet.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Get. %v %v", ctx, id)
- return
- }
- // GetAfterCounter returns a count of finished ThingNotificationRepositoryMock.Get invocations
- func (mmGet *ThingNotificationRepositoryMock) GetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
- }
- // GetBeforeCounter returns a count of ThingNotificationRepositoryMock.Get invocations
- func (mmGet *ThingNotificationRepositoryMock) GetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
- }
- // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Get.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGet *mThingNotificationRepositoryMockGet) Calls() []*ThingNotificationRepositoryMockGetParams {
- mmGet.mutex.RLock()
- argCopy := make([]*ThingNotificationRepositoryMockGetParams, 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 *ThingNotificationRepositoryMock) MinimockGetDone() bool {
- if m.GetMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetMock.invocationsDone()
- }
- // MinimockGetInspect logs each unmet expectation
- func (m *ThingNotificationRepositoryMock) MinimockGetInspect() {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Get with params: %#v", *e.params)
- }
- }
- afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
- if m.GetMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingNotificationRepositoryMock.Get")
- } else {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGet != nil && afterGetCounter < 1 {
- m.t.Error("Expected call to ThingNotificationRepositoryMock.Get")
- }
- if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Get but found %d calls",
- mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
- }
- }
- type mThingNotificationRepositoryMockGetExpired struct {
- optional bool
- mock *ThingNotificationRepositoryMock
- defaultExpectation *ThingNotificationRepositoryMockGetExpiredExpectation
- expectations []*ThingNotificationRepositoryMockGetExpiredExpectation
- callArgs []*ThingNotificationRepositoryMockGetExpiredParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingNotificationRepositoryMockGetExpiredExpectation specifies expectation struct of the ThingNotificationRepository.GetExpired
- type ThingNotificationRepositoryMockGetExpiredExpectation struct {
- mock *ThingNotificationRepositoryMock
- params *ThingNotificationRepositoryMockGetExpiredParams
- paramPtrs *ThingNotificationRepositoryMockGetExpiredParamPtrs
- results *ThingNotificationRepositoryMockGetExpiredResults
- Counter uint64
- }
- // ThingNotificationRepositoryMockGetExpiredParams contains parameters of the ThingNotificationRepository.GetExpired
- type ThingNotificationRepositoryMockGetExpiredParams struct {
- ctx context.Context
- }
- // ThingNotificationRepositoryMockGetExpiredParamPtrs contains pointers to parameters of the ThingNotificationRepository.GetExpired
- type ThingNotificationRepositoryMockGetExpiredParamPtrs struct {
- ctx *context.Context
- }
- // ThingNotificationRepositoryMockGetExpiredResults contains results of the ThingNotificationRepository.GetExpired
- type ThingNotificationRepositoryMockGetExpiredResults struct {
- ea1 []models.ExtThingNotification
- 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 (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Optional() *mThingNotificationRepositoryMockGetExpired {
- mmGetExpired.optional = true
- return mmGetExpired
- }
- // Expect sets up expected params for ThingNotificationRepository.GetExpired
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Expect(ctx context.Context) *mThingNotificationRepositoryMockGetExpired {
- if mmGetExpired.mock.funcGetExpired != nil {
- mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
- }
- if mmGetExpired.defaultExpectation == nil {
- mmGetExpired.defaultExpectation = &ThingNotificationRepositoryMockGetExpiredExpectation{}
- }
- if mmGetExpired.defaultExpectation.paramPtrs != nil {
- mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by ExpectParams functions")
- }
- mmGetExpired.defaultExpectation.params = &ThingNotificationRepositoryMockGetExpiredParams{ctx}
- for _, e := range mmGetExpired.expectations {
- if minimock.Equal(e.params, mmGetExpired.defaultExpectation.params) {
- mmGetExpired.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetExpired.defaultExpectation.params)
- }
- }
- return mmGetExpired
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.GetExpired
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockGetExpired {
- if mmGetExpired.mock.funcGetExpired != nil {
- mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
- }
- if mmGetExpired.defaultExpectation == nil {
- mmGetExpired.defaultExpectation = &ThingNotificationRepositoryMockGetExpiredExpectation{}
- }
- if mmGetExpired.defaultExpectation.params != nil {
- mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Expect")
- }
- if mmGetExpired.defaultExpectation.paramPtrs == nil {
- mmGetExpired.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockGetExpiredParamPtrs{}
- }
- mmGetExpired.defaultExpectation.paramPtrs.ctx = &ctx
- return mmGetExpired
- }
- // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.GetExpired
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Inspect(f func(ctx context.Context)) *mThingNotificationRepositoryMockGetExpired {
- if mmGetExpired.mock.inspectFuncGetExpired != nil {
- mmGetExpired.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.GetExpired")
- }
- mmGetExpired.mock.inspectFuncGetExpired = f
- return mmGetExpired
- }
- // Return sets up results that will be returned by ThingNotificationRepository.GetExpired
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Return(ea1 []models.ExtThingNotification, err error) *ThingNotificationRepositoryMock {
- if mmGetExpired.mock.funcGetExpired != nil {
- mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
- }
- if mmGetExpired.defaultExpectation == nil {
- mmGetExpired.defaultExpectation = &ThingNotificationRepositoryMockGetExpiredExpectation{mock: mmGetExpired.mock}
- }
- mmGetExpired.defaultExpectation.results = &ThingNotificationRepositoryMockGetExpiredResults{ea1, err}
- return mmGetExpired.mock
- }
- // Set uses given function f to mock the ThingNotificationRepository.GetExpired method
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Set(f func(ctx context.Context) (ea1 []models.ExtThingNotification, err error)) *ThingNotificationRepositoryMock {
- if mmGetExpired.defaultExpectation != nil {
- mmGetExpired.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.GetExpired method")
- }
- if len(mmGetExpired.expectations) > 0 {
- mmGetExpired.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.GetExpired method")
- }
- mmGetExpired.mock.funcGetExpired = f
- return mmGetExpired.mock
- }
- // When sets expectation for the ThingNotificationRepository.GetExpired which will trigger the result defined by the following
- // Then helper
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) When(ctx context.Context) *ThingNotificationRepositoryMockGetExpiredExpectation {
- if mmGetExpired.mock.funcGetExpired != nil {
- mmGetExpired.mock.t.Fatalf("ThingNotificationRepositoryMock.GetExpired mock is already set by Set")
- }
- expectation := &ThingNotificationRepositoryMockGetExpiredExpectation{
- mock: mmGetExpired.mock,
- params: &ThingNotificationRepositoryMockGetExpiredParams{ctx},
- }
- mmGetExpired.expectations = append(mmGetExpired.expectations, expectation)
- return expectation
- }
- // Then sets up ThingNotificationRepository.GetExpired return parameters for the expectation previously defined by the When method
- func (e *ThingNotificationRepositoryMockGetExpiredExpectation) Then(ea1 []models.ExtThingNotification, err error) *ThingNotificationRepositoryMock {
- e.results = &ThingNotificationRepositoryMockGetExpiredResults{ea1, err}
- return e.mock
- }
- // Times sets number of times ThingNotificationRepository.GetExpired should be invoked
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Times(n uint64) *mThingNotificationRepositoryMockGetExpired {
- if n == 0 {
- mmGetExpired.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.GetExpired mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmGetExpired.expectedInvocations, n)
- return mmGetExpired
- }
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) invocationsDone() bool {
- if len(mmGetExpired.expectations) == 0 && mmGetExpired.defaultExpectation == nil && mmGetExpired.mock.funcGetExpired == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmGetExpired.mock.afterGetExpiredCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmGetExpired.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // GetExpired implements notification.ThingNotificationRepository
- func (mmGetExpired *ThingNotificationRepositoryMock) GetExpired(ctx context.Context) (ea1 []models.ExtThingNotification, err error) {
- mm_atomic.AddUint64(&mmGetExpired.beforeGetExpiredCounter, 1)
- defer mm_atomic.AddUint64(&mmGetExpired.afterGetExpiredCounter, 1)
- if mmGetExpired.inspectFuncGetExpired != nil {
- mmGetExpired.inspectFuncGetExpired(ctx)
- }
- mm_params := ThingNotificationRepositoryMockGetExpiredParams{ctx}
- // Record call args
- mmGetExpired.GetExpiredMock.mutex.Lock()
- mmGetExpired.GetExpiredMock.callArgs = append(mmGetExpired.GetExpiredMock.callArgs, &mm_params)
- mmGetExpired.GetExpiredMock.mutex.Unlock()
- for _, e := range mmGetExpired.GetExpiredMock.expectations {
- if minimock.Equal(*e.params, mm_params) {
- mm_atomic.AddUint64(&e.Counter, 1)
- return e.results.ea1, e.results.err
- }
- }
- if mmGetExpired.GetExpiredMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGetExpired.GetExpiredMock.defaultExpectation.Counter, 1)
- mm_want := mmGetExpired.GetExpiredMock.defaultExpectation.params
- mm_want_ptrs := mmGetExpired.GetExpiredMock.defaultExpectation.paramPtrs
- mm_got := ThingNotificationRepositoryMockGetExpiredParams{ctx}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmGetExpired.t.Errorf("ThingNotificationRepositoryMock.GetExpired 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))
- }
- } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGetExpired.t.Errorf("ThingNotificationRepositoryMock.GetExpired got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
- }
- mm_results := mmGetExpired.GetExpiredMock.defaultExpectation.results
- if mm_results == nil {
- mmGetExpired.t.Fatal("No results are set for the ThingNotificationRepositoryMock.GetExpired")
- }
- return (*mm_results).ea1, (*mm_results).err
- }
- if mmGetExpired.funcGetExpired != nil {
- return mmGetExpired.funcGetExpired(ctx)
- }
- mmGetExpired.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.GetExpired. %v", ctx)
- return
- }
- // GetExpiredAfterCounter returns a count of finished ThingNotificationRepositoryMock.GetExpired invocations
- func (mmGetExpired *ThingNotificationRepositoryMock) GetExpiredAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetExpired.afterGetExpiredCounter)
- }
- // GetExpiredBeforeCounter returns a count of ThingNotificationRepositoryMock.GetExpired invocations
- func (mmGetExpired *ThingNotificationRepositoryMock) GetExpiredBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGetExpired.beforeGetExpiredCounter)
- }
- // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.GetExpired.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGetExpired *mThingNotificationRepositoryMockGetExpired) Calls() []*ThingNotificationRepositoryMockGetExpiredParams {
- mmGetExpired.mutex.RLock()
- argCopy := make([]*ThingNotificationRepositoryMockGetExpiredParams, len(mmGetExpired.callArgs))
- copy(argCopy, mmGetExpired.callArgs)
- mmGetExpired.mutex.RUnlock()
- return argCopy
- }
- // MinimockGetExpiredDone returns true if the count of the GetExpired invocations corresponds
- // the number of defined expectations
- func (m *ThingNotificationRepositoryMock) MinimockGetExpiredDone() bool {
- if m.GetExpiredMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.GetExpiredMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.GetExpiredMock.invocationsDone()
- }
- // MinimockGetExpiredInspect logs each unmet expectation
- func (m *ThingNotificationRepositoryMock) MinimockGetExpiredInspect() {
- for _, e := range m.GetExpiredMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.GetExpired with params: %#v", *e.params)
- }
- }
- afterGetExpiredCounter := mm_atomic.LoadUint64(&m.afterGetExpiredCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.GetExpiredMock.defaultExpectation != nil && afterGetExpiredCounter < 1 {
- if m.GetExpiredMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingNotificationRepositoryMock.GetExpired")
- } else {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.GetExpired with params: %#v", *m.GetExpiredMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcGetExpired != nil && afterGetExpiredCounter < 1 {
- m.t.Error("Expected call to ThingNotificationRepositoryMock.GetExpired")
- }
- if !m.GetExpiredMock.invocationsDone() && afterGetExpiredCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.GetExpired but found %d calls",
- mm_atomic.LoadUint64(&m.GetExpiredMock.expectedInvocations), afterGetExpiredCounter)
- }
- }
- type mThingNotificationRepositoryMockUpdate struct {
- optional bool
- mock *ThingNotificationRepositoryMock
- defaultExpectation *ThingNotificationRepositoryMockUpdateExpectation
- expectations []*ThingNotificationRepositoryMockUpdateExpectation
- callArgs []*ThingNotificationRepositoryMockUpdateParams
- mutex sync.RWMutex
- expectedInvocations uint64
- }
- // ThingNotificationRepositoryMockUpdateExpectation specifies expectation struct of the ThingNotificationRepository.Update
- type ThingNotificationRepositoryMockUpdateExpectation struct {
- mock *ThingNotificationRepositoryMock
- params *ThingNotificationRepositoryMockUpdateParams
- paramPtrs *ThingNotificationRepositoryMockUpdateParamPtrs
- results *ThingNotificationRepositoryMockUpdateResults
- Counter uint64
- }
- // ThingNotificationRepositoryMockUpdateParams contains parameters of the ThingNotificationRepository.Update
- type ThingNotificationRepositoryMockUpdateParams struct {
- ctx context.Context
- req models.UpdateThingNotificationRequest
- }
- // ThingNotificationRepositoryMockUpdateParamPtrs contains pointers to parameters of the ThingNotificationRepository.Update
- type ThingNotificationRepositoryMockUpdateParamPtrs struct {
- ctx *context.Context
- req *models.UpdateThingNotificationRequest
- }
- // ThingNotificationRepositoryMockUpdateResults contains results of the ThingNotificationRepository.Update
- type ThingNotificationRepositoryMockUpdateResults 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 (mmUpdate *mThingNotificationRepositoryMockUpdate) Optional() *mThingNotificationRepositoryMockUpdate {
- mmUpdate.optional = true
- return mmUpdate
- }
- // Expect sets up expected params for ThingNotificationRepository.Update
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingNotificationRequest) *mThingNotificationRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.paramPtrs != nil {
- mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by ExpectParams functions")
- }
- mmUpdate.defaultExpectation.params = &ThingNotificationRepositoryMockUpdateParams{ctx, req}
- 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
- }
- // ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.Update
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.params != nil {
- mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Expect")
- }
- if mmUpdate.defaultExpectation.paramPtrs == nil {
- mmUpdate.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockUpdateParamPtrs{}
- }
- mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx
- return mmUpdate
- }
- // ExpectReqParam2 sets up expected param req for ThingNotificationRepository.Update
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) ExpectReqParam2(req models.UpdateThingNotificationRequest) *mThingNotificationRepositoryMockUpdate {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{}
- }
- if mmUpdate.defaultExpectation.params != nil {
- mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Expect")
- }
- if mmUpdate.defaultExpectation.paramPtrs == nil {
- mmUpdate.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockUpdateParamPtrs{}
- }
- mmUpdate.defaultExpectation.paramPtrs.req = &req
- return mmUpdate
- }
- // Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Update
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingNotificationRequest)) *mThingNotificationRepositoryMockUpdate {
- if mmUpdate.mock.inspectFuncUpdate != nil {
- mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Update")
- }
- mmUpdate.mock.inspectFuncUpdate = f
- return mmUpdate
- }
- // Return sets up results that will be returned by ThingNotificationRepository.Update
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) Return(err error) *ThingNotificationRepositoryMock {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
- }
- if mmUpdate.defaultExpectation == nil {
- mmUpdate.defaultExpectation = &ThingNotificationRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
- }
- mmUpdate.defaultExpectation.results = &ThingNotificationRepositoryMockUpdateResults{err}
- return mmUpdate.mock
- }
- // Set uses given function f to mock the ThingNotificationRepository.Update method
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingNotificationRequest) (err error)) *ThingNotificationRepositoryMock {
- if mmUpdate.defaultExpectation != nil {
- mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Update method")
- }
- if len(mmUpdate.expectations) > 0 {
- mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Update method")
- }
- mmUpdate.mock.funcUpdate = f
- return mmUpdate.mock
- }
- // When sets expectation for the ThingNotificationRepository.Update which will trigger the result defined by the following
- // Then helper
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingNotificationRequest) *ThingNotificationRepositoryMockUpdateExpectation {
- if mmUpdate.mock.funcUpdate != nil {
- mmUpdate.mock.t.Fatalf("ThingNotificationRepositoryMock.Update mock is already set by Set")
- }
- expectation := &ThingNotificationRepositoryMockUpdateExpectation{
- mock: mmUpdate.mock,
- params: &ThingNotificationRepositoryMockUpdateParams{ctx, req},
- }
- mmUpdate.expectations = append(mmUpdate.expectations, expectation)
- return expectation
- }
- // Then sets up ThingNotificationRepository.Update return parameters for the expectation previously defined by the When method
- func (e *ThingNotificationRepositoryMockUpdateExpectation) Then(err error) *ThingNotificationRepositoryMock {
- e.results = &ThingNotificationRepositoryMockUpdateResults{err}
- return e.mock
- }
- // Times sets number of times ThingNotificationRepository.Update should be invoked
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) Times(n uint64) *mThingNotificationRepositoryMockUpdate {
- if n == 0 {
- mmUpdate.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Update mock can not be zero")
- }
- mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
- return mmUpdate
- }
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) invocationsDone() bool {
- if len(mmUpdate.expectations) == 0 && mmUpdate.defaultExpectation == nil && mmUpdate.mock.funcUpdate == nil {
- return true
- }
- totalInvocations := mm_atomic.LoadUint64(&mmUpdate.mock.afterUpdateCounter)
- expectedInvocations := mm_atomic.LoadUint64(&mmUpdate.expectedInvocations)
- return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
- }
- // Update implements notification.ThingNotificationRepository
- func (mmUpdate *ThingNotificationRepositoryMock) Update(ctx context.Context, req models.UpdateThingNotificationRequest) (err error) {
- mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
- defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
- if mmUpdate.inspectFuncUpdate != nil {
- mmUpdate.inspectFuncUpdate(ctx, req)
- }
- mm_params := ThingNotificationRepositoryMockUpdateParams{ctx, req}
- // 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_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs
- mm_got := ThingNotificationRepositoryMockUpdateParams{ctx, req}
- if mm_want_ptrs != nil {
- if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
- mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update 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) {
- mmUpdate.t.Errorf("ThingNotificationRepositoryMock.Update 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) {
- mmUpdate.t.Errorf("ThingNotificationRepositoryMock.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 ThingNotificationRepositoryMock.Update")
- }
- return (*mm_results).err
- }
- if mmUpdate.funcUpdate != nil {
- return mmUpdate.funcUpdate(ctx, req)
- }
- mmUpdate.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Update. %v %v", ctx, req)
- return
- }
- // UpdateAfterCounter returns a count of finished ThingNotificationRepositoryMock.Update invocations
- func (mmUpdate *ThingNotificationRepositoryMock) UpdateAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
- }
- // UpdateBeforeCounter returns a count of ThingNotificationRepositoryMock.Update invocations
- func (mmUpdate *ThingNotificationRepositoryMock) UpdateBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
- }
- // Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Update.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmUpdate *mThingNotificationRepositoryMockUpdate) Calls() []*ThingNotificationRepositoryMockUpdateParams {
- mmUpdate.mutex.RLock()
- argCopy := make([]*ThingNotificationRepositoryMockUpdateParams, 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 *ThingNotificationRepositoryMock) MinimockUpdateDone() bool {
- if m.UpdateMock.optional {
- // Optional methods provide '0 or more' call count restriction.
- return true
- }
- for _, e := range m.UpdateMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- return false
- }
- }
- return m.UpdateMock.invocationsDone()
- }
- // MinimockUpdateInspect logs each unmet expectation
- func (m *ThingNotificationRepositoryMock) MinimockUpdateInspect() {
- for _, e := range m.UpdateMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Update with params: %#v", *e.params)
- }
- }
- afterUpdateCounter := mm_atomic.LoadUint64(&m.afterUpdateCounter)
- // if default expectation was set then invocations count should be greater than zero
- if m.UpdateMock.defaultExpectation != nil && afterUpdateCounter < 1 {
- if m.UpdateMock.defaultExpectation.params == nil {
- m.t.Error("Expected call to ThingNotificationRepositoryMock.Update")
- } else {
- m.t.Errorf("Expected call to ThingNotificationRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
- }
- }
- // if func was set then invocations count should be greater than zero
- if m.funcUpdate != nil && afterUpdateCounter < 1 {
- m.t.Error("Expected call to ThingNotificationRepositoryMock.Update")
- }
- if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
- m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Update but found %d calls",
- mm_atomic.LoadUint64(&m.UpdateMock.expectedInvocations), afterUpdateCounter)
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *ThingNotificationRepositoryMock) MinimockFinish() {
- m.finishOnce.Do(func() {
- if !m.minimockDone() {
- m.MinimockAddInspect()
- m.MinimockDeleteInspect()
- m.MinimockGetInspect()
- m.MinimockGetExpiredInspect()
- m.MinimockUpdateInspect()
- }
- })
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *ThingNotificationRepositoryMock) 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 *ThingNotificationRepositoryMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockAddDone() &&
- m.MinimockDeleteDone() &&
- m.MinimockGetDone() &&
- m.MinimockGetExpiredDone() &&
- m.MinimockUpdateDone()
- }
|