|
@@ -2371,6 +2371,159 @@ func (c PermsStoreSetRepoPermsFuncCall) Results() []interface{} {
|
|
|
return []interface{}{c.Result0}
|
|
|
}
|
|
|
|
|
|
+// MockReposStore is a mock implementation of the ReposStore interface (from
|
|
|
+// the package gogs.io/gogs/internal/db) used for unit testing.
|
|
|
+type MockReposStore struct {
|
|
|
+ // GetByNameFunc is an instance of a mock function object controlling
|
|
|
+ // the behavior of the method GetByName.
|
|
|
+ GetByNameFunc *ReposStoreGetByNameFunc
|
|
|
+}
|
|
|
+
|
|
|
+// NewMockReposStore creates a new mock of the ReposStore interface. All
|
|
|
+// methods return zero values for all results, unless overwritten.
|
|
|
+func NewMockReposStore() *MockReposStore {
|
|
|
+ return &MockReposStore{
|
|
|
+ GetByNameFunc: &ReposStoreGetByNameFunc{
|
|
|
+ defaultHook: func(context.Context, int64, string) (r0 *Repository, r1 error) {
|
|
|
+ return
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// NewStrictMockReposStore creates a new mock of the ReposStore interface.
|
|
|
+// All methods panic on invocation, unless overwritten.
|
|
|
+func NewStrictMockReposStore() *MockReposStore {
|
|
|
+ return &MockReposStore{
|
|
|
+ GetByNameFunc: &ReposStoreGetByNameFunc{
|
|
|
+ defaultHook: func(context.Context, int64, string) (*Repository, error) {
|
|
|
+ panic("unexpected invocation of MockReposStore.GetByName")
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// NewMockReposStoreFrom creates a new mock of the MockReposStore interface.
|
|
|
+// All methods delegate to the given implementation, unless overwritten.
|
|
|
+func NewMockReposStoreFrom(i ReposStore) *MockReposStore {
|
|
|
+ return &MockReposStore{
|
|
|
+ GetByNameFunc: &ReposStoreGetByNameFunc{
|
|
|
+ defaultHook: i.GetByName,
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ReposStoreGetByNameFunc describes the behavior when the GetByName method
|
|
|
+// of the parent MockReposStore instance is invoked.
|
|
|
+type ReposStoreGetByNameFunc struct {
|
|
|
+ defaultHook func(context.Context, int64, string) (*Repository, error)
|
|
|
+ hooks []func(context.Context, int64, string) (*Repository, error)
|
|
|
+ history []ReposStoreGetByNameFuncCall
|
|
|
+ mutex sync.Mutex
|
|
|
+}
|
|
|
+
|
|
|
+// GetByName delegates to the next hook function in the queue and stores the
|
|
|
+// parameter and result values of this invocation.
|
|
|
+func (m *MockReposStore) GetByName(v0 context.Context, v1 int64, v2 string) (*Repository, error) {
|
|
|
+ r0, r1 := m.GetByNameFunc.nextHook()(v0, v1, v2)
|
|
|
+ m.GetByNameFunc.appendCall(ReposStoreGetByNameFuncCall{v0, v1, v2, r0, r1})
|
|
|
+ return r0, r1
|
|
|
+}
|
|
|
+
|
|
|
+// SetDefaultHook sets function that is called when the GetByName method of
|
|
|
+// the parent MockReposStore instance is invoked and the hook queue is
|
|
|
+// empty.
|
|
|
+func (f *ReposStoreGetByNameFunc) SetDefaultHook(hook func(context.Context, int64, string) (*Repository, error)) {
|
|
|
+ f.defaultHook = hook
|
|
|
+}
|
|
|
+
|
|
|
+// PushHook adds a function to the end of hook queue. Each invocation of the
|
|
|
+// GetByName method of the parent MockReposStore instance invokes the hook
|
|
|
+// at the front of the queue and discards it. After the queue is empty, the
|
|
|
+// default hook function is invoked for any future action.
|
|
|
+func (f *ReposStoreGetByNameFunc) PushHook(hook func(context.Context, int64, string) (*Repository, error)) {
|
|
|
+ f.mutex.Lock()
|
|
|
+ f.hooks = append(f.hooks, hook)
|
|
|
+ f.mutex.Unlock()
|
|
|
+}
|
|
|
+
|
|
|
+// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
|
|
+// given values.
|
|
|
+func (f *ReposStoreGetByNameFunc) SetDefaultReturn(r0 *Repository, r1 error) {
|
|
|
+ f.SetDefaultHook(func(context.Context, int64, string) (*Repository, error) {
|
|
|
+ return r0, r1
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// PushReturn calls PushHook with a function that returns the given values.
|
|
|
+func (f *ReposStoreGetByNameFunc) PushReturn(r0 *Repository, r1 error) {
|
|
|
+ f.PushHook(func(context.Context, int64, string) (*Repository, error) {
|
|
|
+ return r0, r1
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func (f *ReposStoreGetByNameFunc) nextHook() func(context.Context, int64, string) (*Repository, error) {
|
|
|
+ f.mutex.Lock()
|
|
|
+ defer f.mutex.Unlock()
|
|
|
+
|
|
|
+ if len(f.hooks) == 0 {
|
|
|
+ return f.defaultHook
|
|
|
+ }
|
|
|
+
|
|
|
+ hook := f.hooks[0]
|
|
|
+ f.hooks = f.hooks[1:]
|
|
|
+ return hook
|
|
|
+}
|
|
|
+
|
|
|
+func (f *ReposStoreGetByNameFunc) appendCall(r0 ReposStoreGetByNameFuncCall) {
|
|
|
+ f.mutex.Lock()
|
|
|
+ f.history = append(f.history, r0)
|
|
|
+ f.mutex.Unlock()
|
|
|
+}
|
|
|
+
|
|
|
+// History returns a sequence of ReposStoreGetByNameFuncCall objects
|
|
|
+// describing the invocations of this function.
|
|
|
+func (f *ReposStoreGetByNameFunc) History() []ReposStoreGetByNameFuncCall {
|
|
|
+ f.mutex.Lock()
|
|
|
+ history := make([]ReposStoreGetByNameFuncCall, len(f.history))
|
|
|
+ copy(history, f.history)
|
|
|
+ f.mutex.Unlock()
|
|
|
+
|
|
|
+ return history
|
|
|
+}
|
|
|
+
|
|
|
+// ReposStoreGetByNameFuncCall is an object that describes an invocation of
|
|
|
+// method GetByName on an instance of MockReposStore.
|
|
|
+type ReposStoreGetByNameFuncCall struct {
|
|
|
+ // Arg0 is the value of the 1st argument passed to this method
|
|
|
+ // invocation.
|
|
|
+ Arg0 context.Context
|
|
|
+ // Arg1 is the value of the 2nd argument passed to this method
|
|
|
+ // invocation.
|
|
|
+ Arg1 int64
|
|
|
+ // Arg2 is the value of the 3rd argument passed to this method
|
|
|
+ // invocation.
|
|
|
+ Arg2 string
|
|
|
+ // Result0 is the value of the 1st result returned from this method
|
|
|
+ // invocation.
|
|
|
+ Result0 *Repository
|
|
|
+ // Result1 is the value of the 2nd result returned from this method
|
|
|
+ // invocation.
|
|
|
+ Result1 error
|
|
|
+}
|
|
|
+
|
|
|
+// Args returns an interface slice containing the arguments of this
|
|
|
+// invocation.
|
|
|
+func (c ReposStoreGetByNameFuncCall) Args() []interface{} {
|
|
|
+ return []interface{}{c.Arg0, c.Arg1, c.Arg2}
|
|
|
+}
|
|
|
+
|
|
|
+// Results returns an interface slice containing the results of this
|
|
|
+// invocation.
|
|
|
+func (c ReposStoreGetByNameFuncCall) Results() []interface{} {
|
|
|
+ return []interface{}{c.Result0, c.Result1}
|
|
|
+}
|
|
|
+
|
|
|
// MockTwoFactorsStore is a mock implementation of the TwoFactorsStore
|
|
|
// interface (from the package gogs.io/gogs/internal/db) used for unit
|
|
|
// testing.
|