123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516 |
- package mocks
- // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
- //go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.UserRepository -o ./mocks/user_repository_minimock.go -n UserRepositoryMock
- import (
- "context"
- "sync"
- mm_atomic "sync/atomic"
- mm_time "time"
- "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
- "github.com/gojuno/minimock/v3"
- )
- // UserRepositoryMock implements interfaces.UserRepository
- type UserRepositoryMock struct {
- t minimock.Tester
- funcAdd func(ctx context.Context, username string, password string) (i1 int, err error)
- inspectFuncAdd func(ctx context.Context, username string, password string)
- afterAddCounter uint64
- beforeAddCounter uint64
- AddMock mUserRepositoryMockAdd
- funcGet func(ctx context.Context, username string) (up1 *models.User, err error)
- inspectFuncGet func(ctx context.Context, username string)
- afterGetCounter uint64
- beforeGetCounter uint64
- GetMock mUserRepositoryMockGet
- }
- // NewUserRepositoryMock returns a mock for interfaces.UserRepository
- func NewUserRepositoryMock(t minimock.Tester) *UserRepositoryMock {
- m := &UserRepositoryMock{t: t}
- if controller, ok := t.(minimock.MockController); ok {
- controller.RegisterMocker(m)
- }
- m.AddMock = mUserRepositoryMockAdd{mock: m}
- m.AddMock.callArgs = []*UserRepositoryMockAddParams{}
- m.GetMock = mUserRepositoryMockGet{mock: m}
- m.GetMock.callArgs = []*UserRepositoryMockGetParams{}
- return m
- }
- type mUserRepositoryMockAdd struct {
- mock *UserRepositoryMock
- defaultExpectation *UserRepositoryMockAddExpectation
- expectations []*UserRepositoryMockAddExpectation
- callArgs []*UserRepositoryMockAddParams
- mutex sync.RWMutex
- }
- // UserRepositoryMockAddExpectation specifies expectation struct of the UserRepository.Add
- type UserRepositoryMockAddExpectation struct {
- mock *UserRepositoryMock
- params *UserRepositoryMockAddParams
- results *UserRepositoryMockAddResults
- Counter uint64
- }
- // UserRepositoryMockAddParams contains parameters of the UserRepository.Add
- type UserRepositoryMockAddParams struct {
- ctx context.Context
- username string
- password string
- }
- // UserRepositoryMockAddResults contains results of the UserRepository.Add
- type UserRepositoryMockAddResults struct {
- i1 int
- err error
- }
- // Expect sets up expected params for UserRepository.Add
- func (mmAdd *mUserRepositoryMockAdd) Expect(ctx context.Context, username string, password string) *mUserRepositoryMockAdd {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{}
- }
- mmAdd.defaultExpectation.params = &UserRepositoryMockAddParams{ctx, username, password}
- 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 UserRepository.Add
- func (mmAdd *mUserRepositoryMockAdd) Inspect(f func(ctx context.Context, username string, password string)) *mUserRepositoryMockAdd {
- if mmAdd.mock.inspectFuncAdd != nil {
- mmAdd.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.Add")
- }
- mmAdd.mock.inspectFuncAdd = f
- return mmAdd
- }
- // Return sets up results that will be returned by UserRepository.Add
- func (mmAdd *mUserRepositoryMockAdd) Return(i1 int, err error) *UserRepositoryMock {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
- }
- if mmAdd.defaultExpectation == nil {
- mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{mock: mmAdd.mock}
- }
- mmAdd.defaultExpectation.results = &UserRepositoryMockAddResults{i1, err}
- return mmAdd.mock
- }
- // Set uses given function f to mock the UserRepository.Add method
- func (mmAdd *mUserRepositoryMockAdd) Set(f func(ctx context.Context, username string, password string) (i1 int, err error)) *UserRepositoryMock {
- if mmAdd.defaultExpectation != nil {
- mmAdd.mock.t.Fatalf("Default expectation is already set for the UserRepository.Add method")
- }
- if len(mmAdd.expectations) > 0 {
- mmAdd.mock.t.Fatalf("Some expectations are already set for the UserRepository.Add method")
- }
- mmAdd.mock.funcAdd = f
- return mmAdd.mock
- }
- // When sets expectation for the UserRepository.Add which will trigger the result defined by the following
- // Then helper
- func (mmAdd *mUserRepositoryMockAdd) When(ctx context.Context, username string, password string) *UserRepositoryMockAddExpectation {
- if mmAdd.mock.funcAdd != nil {
- mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
- }
- expectation := &UserRepositoryMockAddExpectation{
- mock: mmAdd.mock,
- params: &UserRepositoryMockAddParams{ctx, username, password},
- }
- mmAdd.expectations = append(mmAdd.expectations, expectation)
- return expectation
- }
- // Then sets up UserRepository.Add return parameters for the expectation previously defined by the When method
- func (e *UserRepositoryMockAddExpectation) Then(i1 int, err error) *UserRepositoryMock {
- e.results = &UserRepositoryMockAddResults{i1, err}
- return e.mock
- }
- // Add implements interfaces.UserRepository
- func (mmAdd *UserRepositoryMock) Add(ctx context.Context, username string, password string) (i1 int, err error) {
- mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
- defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
- if mmAdd.inspectFuncAdd != nil {
- mmAdd.inspectFuncAdd(ctx, username, password)
- }
- mm_params := &UserRepositoryMockAddParams{ctx, username, password}
- // 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 := UserRepositoryMockAddParams{ctx, username, password}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmAdd.t.Errorf("UserRepositoryMock.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 UserRepositoryMock.Add")
- }
- return (*mm_results).i1, (*mm_results).err
- }
- if mmAdd.funcAdd != nil {
- return mmAdd.funcAdd(ctx, username, password)
- }
- mmAdd.t.Fatalf("Unexpected call to UserRepositoryMock.Add. %v %v %v", ctx, username, password)
- return
- }
- // AddAfterCounter returns a count of finished UserRepositoryMock.Add invocations
- func (mmAdd *UserRepositoryMock) AddAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
- }
- // AddBeforeCounter returns a count of UserRepositoryMock.Add invocations
- func (mmAdd *UserRepositoryMock) AddBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
- }
- // Calls returns a list of arguments used in each call to UserRepositoryMock.Add.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmAdd *mUserRepositoryMockAdd) Calls() []*UserRepositoryMockAddParams {
- mmAdd.mutex.RLock()
- argCopy := make([]*UserRepositoryMockAddParams, 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 *UserRepositoryMock) 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 *UserRepositoryMock) MinimockAddInspect() {
- for _, e := range m.AddMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to UserRepositoryMock.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 UserRepositoryMock.Add")
- } else {
- m.t.Errorf("Expected call to UserRepositoryMock.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 UserRepositoryMock.Add")
- }
- }
- type mUserRepositoryMockGet struct {
- mock *UserRepositoryMock
- defaultExpectation *UserRepositoryMockGetExpectation
- expectations []*UserRepositoryMockGetExpectation
- callArgs []*UserRepositoryMockGetParams
- mutex sync.RWMutex
- }
- // UserRepositoryMockGetExpectation specifies expectation struct of the UserRepository.Get
- type UserRepositoryMockGetExpectation struct {
- mock *UserRepositoryMock
- params *UserRepositoryMockGetParams
- results *UserRepositoryMockGetResults
- Counter uint64
- }
- // UserRepositoryMockGetParams contains parameters of the UserRepository.Get
- type UserRepositoryMockGetParams struct {
- ctx context.Context
- username string
- }
- // UserRepositoryMockGetResults contains results of the UserRepository.Get
- type UserRepositoryMockGetResults struct {
- up1 *models.User
- err error
- }
- // Expect sets up expected params for UserRepository.Get
- func (mmGet *mUserRepositoryMockGet) Expect(ctx context.Context, username string) *mUserRepositoryMockGet {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &UserRepositoryMockGetExpectation{}
- }
- mmGet.defaultExpectation.params = &UserRepositoryMockGetParams{ctx, username}
- 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 UserRepository.Get
- func (mmGet *mUserRepositoryMockGet) Inspect(f func(ctx context.Context, username string)) *mUserRepositoryMockGet {
- if mmGet.mock.inspectFuncGet != nil {
- mmGet.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.Get")
- }
- mmGet.mock.inspectFuncGet = f
- return mmGet
- }
- // Return sets up results that will be returned by UserRepository.Get
- func (mmGet *mUserRepositoryMockGet) Return(up1 *models.User, err error) *UserRepositoryMock {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
- }
- if mmGet.defaultExpectation == nil {
- mmGet.defaultExpectation = &UserRepositoryMockGetExpectation{mock: mmGet.mock}
- }
- mmGet.defaultExpectation.results = &UserRepositoryMockGetResults{up1, err}
- return mmGet.mock
- }
- // Set uses given function f to mock the UserRepository.Get method
- func (mmGet *mUserRepositoryMockGet) Set(f func(ctx context.Context, username string) (up1 *models.User, err error)) *UserRepositoryMock {
- if mmGet.defaultExpectation != nil {
- mmGet.mock.t.Fatalf("Default expectation is already set for the UserRepository.Get method")
- }
- if len(mmGet.expectations) > 0 {
- mmGet.mock.t.Fatalf("Some expectations are already set for the UserRepository.Get method")
- }
- mmGet.mock.funcGet = f
- return mmGet.mock
- }
- // When sets expectation for the UserRepository.Get which will trigger the result defined by the following
- // Then helper
- func (mmGet *mUserRepositoryMockGet) When(ctx context.Context, username string) *UserRepositoryMockGetExpectation {
- if mmGet.mock.funcGet != nil {
- mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
- }
- expectation := &UserRepositoryMockGetExpectation{
- mock: mmGet.mock,
- params: &UserRepositoryMockGetParams{ctx, username},
- }
- mmGet.expectations = append(mmGet.expectations, expectation)
- return expectation
- }
- // Then sets up UserRepository.Get return parameters for the expectation previously defined by the When method
- func (e *UserRepositoryMockGetExpectation) Then(up1 *models.User, err error) *UserRepositoryMock {
- e.results = &UserRepositoryMockGetResults{up1, err}
- return e.mock
- }
- // Get implements interfaces.UserRepository
- func (mmGet *UserRepositoryMock) Get(ctx context.Context, username string) (up1 *models.User, err error) {
- mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
- defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
- if mmGet.inspectFuncGet != nil {
- mmGet.inspectFuncGet(ctx, username)
- }
- mm_params := &UserRepositoryMockGetParams{ctx, username}
- // 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.up1, e.results.err
- }
- }
- if mmGet.GetMock.defaultExpectation != nil {
- mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
- mm_want := mmGet.GetMock.defaultExpectation.params
- mm_got := UserRepositoryMockGetParams{ctx, username}
- if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
- mmGet.t.Errorf("UserRepositoryMock.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 UserRepositoryMock.Get")
- }
- return (*mm_results).up1, (*mm_results).err
- }
- if mmGet.funcGet != nil {
- return mmGet.funcGet(ctx, username)
- }
- mmGet.t.Fatalf("Unexpected call to UserRepositoryMock.Get. %v %v", ctx, username)
- return
- }
- // GetAfterCounter returns a count of finished UserRepositoryMock.Get invocations
- func (mmGet *UserRepositoryMock) GetAfterCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
- }
- // GetBeforeCounter returns a count of UserRepositoryMock.Get invocations
- func (mmGet *UserRepositoryMock) GetBeforeCounter() uint64 {
- return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
- }
- // Calls returns a list of arguments used in each call to UserRepositoryMock.Get.
- // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
- func (mmGet *mUserRepositoryMockGet) Calls() []*UserRepositoryMockGetParams {
- mmGet.mutex.RLock()
- argCopy := make([]*UserRepositoryMockGetParams, 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 *UserRepositoryMock) 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 *UserRepositoryMock) MinimockGetInspect() {
- for _, e := range m.GetMock.expectations {
- if mm_atomic.LoadUint64(&e.Counter) < 1 {
- m.t.Errorf("Expected call to UserRepositoryMock.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 UserRepositoryMock.Get")
- } else {
- m.t.Errorf("Expected call to UserRepositoryMock.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 UserRepositoryMock.Get")
- }
- }
- // MinimockFinish checks that all mocked methods have been called the expected number of times
- func (m *UserRepositoryMock) MinimockFinish() {
- if !m.minimockDone() {
- m.MinimockAddInspect()
- m.MinimockGetInspect()
- m.t.FailNow()
- }
- }
- // MinimockWait waits for all mocked methods to be called the expected number of times
- func (m *UserRepositoryMock) 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 *UserRepositoryMock) minimockDone() bool {
- done := true
- return done &&
- m.MinimockAddDone() &&
- m.MinimockGetDone()
- }
|