diff --git a/internal/context/go_get.go b/internal/context/go_get.go index 811098459..fbb3185f8 100644 --- a/internal/context/go_get.go +++ b/internal/context/go_get.go @@ -29,7 +29,7 @@ func ServeGoGet() macaron.Handler { owner, err := database.Users.GetByUsername(c.Req.Context(), ownerName) if err == nil { - repo, err := database.Repos.GetByName(c.Req.Context(), owner.ID, repoName) + repo, err := database.Handle.Repositories().GetByName(c.Req.Context(), owner.ID, repoName) if err == nil && repo.DefaultBranch != "" { branchName = repo.DefaultBranch } diff --git a/internal/context/repo.go b/internal/context/repo.go index 2123df1d6..519af4deb 100644 --- a/internal/context/repo.go +++ b/internal/context/repo.go @@ -403,7 +403,7 @@ func RepoRef() macaron.Handler { c.Data["IsViewCommit"] = c.Repo.IsViewCommit // People who have push access or have forked repository can propose a new pull request. - if c.Repo.IsWriter() || (c.IsLogged && database.Repos.HasForkedBy(c.Req.Context(), c.Repo.Repository.ID, c.User.ID)) { + if c.Repo.IsWriter() || (c.IsLogged && database.Handle.Repositories().HasForkedBy(c.Req.Context(), c.Repo.Repository.ID, c.User.ID)) { // Pull request is allowed if this is a fork repository // and base repository accepts pull requests. if c.Repo.Repository.BaseRepo != nil { diff --git a/internal/database/actions.go b/internal/database/actions.go index 8dcaeba1f..561a5832d 100644 --- a/internal/database/actions.go +++ b/internal/database/actions.go @@ -124,7 +124,7 @@ func (s *ActionsStore) ListByUser(ctx context.Context, userID, actorID, afterID // notifyWatchers creates rows in action table for watchers who are able to see the action. func (s *ActionsStore) notifyWatchers(ctx context.Context, act *Action) error { - watches, err := NewReposStore(s.db).ListWatches(ctx, act.RepoID) + watches, err := newReposStore(s.db).ListWatches(ctx, act.RepoID) if err != nil { return errors.Wrap(err, "list watches") } @@ -465,7 +465,7 @@ type CommitRepoOptions struct { // regular push also creates a new branch, then another action with type // ActionCreateBranch is created. func (s *ActionsStore) CommitRepo(ctx context.Context, opts CommitRepoOptions) error { - err := NewReposStore(s.db).Touch(ctx, opts.Repo.ID) + err := newReposStore(s.db).Touch(ctx, opts.Repo.ID) if err != nil { return errors.Wrap(err, "touch repository") } @@ -612,7 +612,7 @@ type PushTagOptions struct { // the type ActionDeleteTag is created if the push deletes a tag. Otherwise, an // action with the type ActionPushTag is created for a regular push. func (s *ActionsStore) PushTag(ctx context.Context, opts PushTagOptions) error { - err := NewReposStore(s.db).Touch(ctx, opts.Repo.ID) + err := newReposStore(s.db).Touch(ctx, opts.Repo.ID) if err != nil { return errors.Wrap(err, "touch repository") } diff --git a/internal/database/actions_test.go b/internal/database/actions_test.go index aa1eaa2a5..d3a032358 100644 --- a/internal/database/actions_test.go +++ b/internal/database/actions_test.go @@ -135,7 +135,7 @@ func TestActions(t *testing.T) { func actionsCommitRepo(t *testing.T, ctx context.Context, s *ActionsStore) { alice, err := NewUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", @@ -438,7 +438,7 @@ func actionsListByUser(t *testing.T, ctx context.Context, s *ActionsStore) { func actionsMergePullRequest(t *testing.T, ctx context.Context, s *ActionsStore) { alice, err := NewUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", @@ -483,7 +483,7 @@ func actionsMergePullRequest(t *testing.T, ctx context.Context, s *ActionsStore) func actionsMirrorSyncCreate(t *testing.T, ctx context.Context, s *ActionsStore) { alice, err := NewUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", @@ -524,7 +524,7 @@ func actionsMirrorSyncCreate(t *testing.T, ctx context.Context, s *ActionsStore) func actionsMirrorSyncDelete(t *testing.T, ctx context.Context, s *ActionsStore) { alice, err := NewUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", @@ -565,7 +565,7 @@ func actionsMirrorSyncDelete(t *testing.T, ctx context.Context, s *ActionsStore) func actionsMirrorSyncPush(t *testing.T, ctx context.Context, s *ActionsStore) { alice, err := NewUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", @@ -630,7 +630,7 @@ func actionsMirrorSyncPush(t *testing.T, ctx context.Context, s *ActionsStore) { func actionsNewRepo(t *testing.T, ctx context.Context, s *ActionsStore) { alice, err := NewUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", @@ -709,7 +709,7 @@ func actionsPushTag(t *testing.T, ctx context.Context, s *ActionsStore) { alice, err := NewUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", @@ -801,7 +801,7 @@ func actionsPushTag(t *testing.T, ctx context.Context, s *ActionsStore) { func actionsRenameRepo(t *testing.T, ctx context.Context, s *ActionsStore) { alice, err := NewUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", @@ -840,7 +840,7 @@ func actionsTransferRepo(t *testing.T, ctx context.Context, s *ActionsStore) { require.NoError(t, err) bob, err := NewUsersStore(s.db).Create(ctx, "bob", "bob@example.com", CreateUserOptions{}) require.NoError(t, err) - repo, err := NewReposStore(s.db).Create(ctx, + repo, err := newReposStore(s.db).Create(ctx, alice.ID, CreateRepoOptions{ Name: "example", diff --git a/internal/database/database.go b/internal/database/database.go index 367d717a0..47835c18e 100644 --- a/internal/database/database.go +++ b/internal/database/database.go @@ -123,7 +123,6 @@ func NewConnection(w logger.Writer) (*gorm.DB, error) { } // Initialize stores, sorted in alphabetical order. - Repos = NewReposStore(db) TwoFactors = &twoFactorsStore{DB: db} Users = NewUsersStore(db) @@ -183,3 +182,7 @@ func (db *DB) Permissions() *PermissionsStore { func (db *DB) PublicKey() *PublicKeysStore { return newPublicKeysStore(db.db) } + +func (db *DB) Repositories() *RepositoriesStore { + return newReposStore(db.db) +} diff --git a/internal/database/mocks.go b/internal/database/mocks.go index abc607151..b0da796bf 100644 --- a/internal/database/mocks.go +++ b/internal/database/mocks.go @@ -8,14 +8,6 @@ import ( "testing" ) -func SetMockReposStore(t *testing.T, mock ReposStore) { - before := Repos - Repos = mock - t.Cleanup(func() { - Repos = before - }) -} - func SetMockTwoFactorsStore(t *testing.T, mock TwoFactorsStore) { before := TwoFactors TwoFactors = mock diff --git a/internal/database/repos.go b/internal/database/repositories.go similarity index 64% rename from internal/database/repos.go rename to internal/database/repositories.go index 731c2edd4..c656dc889 100644 --- a/internal/database/repos.go +++ b/internal/database/repositories.go @@ -18,46 +18,6 @@ import ( "gogs.io/gogs/internal/repoutil" ) -// ReposStore is the persistent interface for repositories. -type ReposStore interface { - // Create creates a new repository record in the database. It returns - // ErrNameNotAllowed when the repository name is not allowed, or - // ErrRepoAlreadyExist when a repository with same name already exists for the - // owner. - Create(ctx context.Context, ownerID int64, opts CreateRepoOptions) (*Repository, error) - // GetByCollaboratorID returns a list of repositories that the given - // collaborator has access to. Results are limited to the given limit and sorted - // by the given order (e.g. "updated_unix DESC"). Repositories that are owned - // directly by the given collaborator are not included. - GetByCollaboratorID(ctx context.Context, collaboratorID int64, limit int, orderBy string) ([]*Repository, error) - // GetByCollaboratorIDWithAccessMode returns a list of repositories and - // corresponding access mode that the given collaborator has access to. - // Repositories that are owned directly by the given collaborator are not - // included. - GetByCollaboratorIDWithAccessMode(ctx context.Context, collaboratorID int64) (map[*Repository]AccessMode, error) - // GetByID returns the repository with given ID. It returns ErrRepoNotExist when - // not found. - GetByID(ctx context.Context, id int64) (*Repository, error) - // GetByName returns the repository with given owner and name. It returns - // ErrRepoNotExist when not found. - GetByName(ctx context.Context, ownerID int64, name string) (*Repository, error) - // Star marks the user to star the repository. - Star(ctx context.Context, userID, repoID int64) error - // Touch updates the updated time to the current time and removes the bare state - // of the given repository. - Touch(ctx context.Context, id int64) error - - // ListWatches returns all watches of the given repository. - ListWatches(ctx context.Context, repoID int64) ([]*Watch, error) - // Watch marks the user to watch the repository. - Watch(ctx context.Context, userID, repoID int64) error - - // HasForkedBy returns true if the given repository has forked by the given user. - HasForkedBy(ctx context.Context, repoID, userID int64) bool -} - -var Repos ReposStore - // BeforeCreate implements the GORM create hook. func (r *Repository) BeforeCreate(tx *gorm.DB) error { if r.CreatedUnix == 0 { @@ -119,16 +79,13 @@ func (r *Repository) APIFormat(owner *User, opts ...RepositoryAPIFormatOptions) } } -var _ ReposStore = (*reposStore)(nil) - -type reposStore struct { - *gorm.DB +// RepositoriesStore is the storage layer for repositories. +type RepositoriesStore struct { + db *gorm.DB } -// NewReposStore returns a persistent interface for repositories with given -// database connection. -func NewReposStore(db *gorm.DB) ReposStore { - return &reposStore{DB: db} +func newReposStore(db *gorm.DB) *RepositoriesStore { + return &RepositoriesStore{db: db} } type ErrRepoAlreadyExist struct { @@ -157,7 +114,11 @@ type CreateRepoOptions struct { ForkID int64 } -func (s *reposStore) Create(ctx context.Context, ownerID int64, opts CreateRepoOptions) (*Repository, error) { +// Create creates a new repository record in the database. It returns +// ErrNameNotAllowed when the repository name is not allowed, or +// ErrRepoAlreadyExist when a repository with same name already exists for the +// owner. +func (s *RepositoriesStore) Create(ctx context.Context, ownerID int64, opts CreateRepoOptions) (*Repository, error) { err := isRepoNameAllowed(opts.Name) if err != nil { return nil, err @@ -189,13 +150,13 @@ func (s *reposStore) Create(ctx context.Context, ownerID int64, opts CreateRepoO IsFork: opts.Fork, ForkID: opts.ForkID, } - return repo, s.WithContext(ctx).Transaction(func(tx *gorm.DB) error { + return repo, s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { err = tx.Create(repo).Error if err != nil { return errors.Wrap(err, "create") } - err = NewReposStore(tx).Watch(ctx, ownerID, repo.ID) + err = newReposStore(tx).Watch(ctx, ownerID, repo.ID) if err != nil { return errors.Wrap(err, "watch") } @@ -203,7 +164,11 @@ func (s *reposStore) Create(ctx context.Context, ownerID int64, opts CreateRepoO }) } -func (s *reposStore) GetByCollaboratorID(ctx context.Context, collaboratorID int64, limit int, orderBy string) ([]*Repository, error) { +// GetByCollaboratorID returns a list of repositories that the given +// collaborator has access to. Results are limited to the given limit and sorted +// by the given order (e.g. "updated_unix DESC"). Repositories that are owned +// directly by the given collaborator are not included. +func (s *RepositoriesStore) GetByCollaboratorID(ctx context.Context, collaboratorID int64, limit int, orderBy string) ([]*Repository, error) { /* Equivalent SQL for PostgreSQL: @@ -214,7 +179,7 @@ func (s *reposStore) GetByCollaboratorID(ctx context.Context, collaboratorID int LIMIT @limit */ var repos []*Repository - return repos, s.WithContext(ctx). + return repos, s.db.WithContext(ctx). Joins("JOIN access ON access.repo_id = repository.id AND access.user_id = ?", collaboratorID). Where("access.mode >= ?", AccessModeRead). Order(orderBy). @@ -223,7 +188,11 @@ func (s *reposStore) GetByCollaboratorID(ctx context.Context, collaboratorID int Error } -func (s *reposStore) GetByCollaboratorIDWithAccessMode(ctx context.Context, collaboratorID int64) (map[*Repository]AccessMode, error) { +// GetByCollaboratorIDWithAccessMode returns a list of repositories and +// corresponding access mode that the given collaborator has access to. +// Repositories that are owned directly by the given collaborator are not +// included. +func (s *RepositoriesStore) GetByCollaboratorIDWithAccessMode(ctx context.Context, collaboratorID int64) (map[*Repository]AccessMode, error) { /* Equivalent SQL for PostgreSQL: @@ -238,7 +207,7 @@ func (s *reposStore) GetByCollaboratorIDWithAccessMode(ctx context.Context, coll *Repository Mode AccessMode } - err := s.WithContext(ctx). + err := s.db.WithContext(ctx). Select("repository.*", "access.mode"). Table("repository"). Joins("JOIN access ON access.repo_id = repository.id AND access.user_id = ?", collaboratorID). @@ -275,11 +244,13 @@ func (ErrRepoNotExist) NotFound() bool { return true } -func (s *reposStore) GetByID(ctx context.Context, id int64) (*Repository, error) { +// GetByID returns the repository with given ID. It returns ErrRepoNotExist when +// not found. +func (s *RepositoriesStore) GetByID(ctx context.Context, id int64) (*Repository, error) { repo := new(Repository) - err := s.WithContext(ctx).Where("id = ?", id).First(repo).Error + err := s.db.WithContext(ctx).Where("id = ?", id).First(repo).Error if err != nil { - if err == gorm.ErrRecordNotFound { + if errors.Is(err, gorm.ErrRecordNotFound) { return nil, ErrRepoNotExist{errutil.Args{"repoID": id}} } return nil, err @@ -287,9 +258,11 @@ func (s *reposStore) GetByID(ctx context.Context, id int64) (*Repository, error) return repo, nil } -func (s *reposStore) GetByName(ctx context.Context, ownerID int64, name string) (*Repository, error) { +// GetByName returns the repository with given owner and name. It returns +// ErrRepoNotExist when not found. +func (s *RepositoriesStore) GetByName(ctx context.Context, ownerID int64, name string) (*Repository, error) { repo := new(Repository) - err := s.WithContext(ctx). + err := s.db.WithContext(ctx). Where("owner_id = ? AND lower_name = ?", ownerID, strings.ToLower(name)). First(repo). Error @@ -307,7 +280,7 @@ func (s *reposStore) GetByName(ctx context.Context, ownerID int64, name string) return repo, nil } -func (s *reposStore) recountStars(tx *gorm.DB, userID, repoID int64) error { +func (s *RepositoriesStore) recountStars(tx *gorm.DB, userID, repoID int64) error { /* Equivalent SQL for PostgreSQL: @@ -350,8 +323,9 @@ func (s *reposStore) recountStars(tx *gorm.DB, userID, repoID int64) error { return nil } -func (s *reposStore) Star(ctx context.Context, userID, repoID int64) error { - return s.WithContext(ctx).Transaction(func(tx *gorm.DB) error { +// Star marks the user to star the repository. +func (s *RepositoriesStore) Star(ctx context.Context, userID, repoID int64) error { + return s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { star := &Star{ UserID: userID, RepoID: repoID, @@ -367,23 +341,26 @@ func (s *reposStore) Star(ctx context.Context, userID, repoID int64) error { }) } -func (s *reposStore) Touch(ctx context.Context, id int64) error { - return s.WithContext(ctx). +// Touch updates the updated time to the current time and removes the bare state +// of the given repository. +func (s *RepositoriesStore) Touch(ctx context.Context, id int64) error { + return s.db.WithContext(ctx). Model(new(Repository)). Where("id = ?", id). Updates(map[string]any{ "is_bare": false, - "updated_unix": s.NowFunc().Unix(), + "updated_unix": s.db.NowFunc().Unix(), }). Error } -func (s *reposStore) ListWatches(ctx context.Context, repoID int64) ([]*Watch, error) { +// ListWatches returns all watches of the given repository. +func (s *RepositoriesStore) ListWatches(ctx context.Context, repoID int64) ([]*Watch, error) { var watches []*Watch - return watches, s.WithContext(ctx).Where("repo_id = ?", repoID).Find(&watches).Error + return watches, s.db.WithContext(ctx).Where("repo_id = ?", repoID).Find(&watches).Error } -func (s *reposStore) recountWatches(tx *gorm.DB, repoID int64) error { +func (s *RepositoriesStore) recountWatches(tx *gorm.DB, repoID int64) error { /* Equivalent SQL for PostgreSQL: @@ -402,8 +379,9 @@ func (s *reposStore) recountWatches(tx *gorm.DB, repoID int64) error { Error } -func (s *reposStore) Watch(ctx context.Context, userID, repoID int64) error { - return s.WithContext(ctx).Transaction(func(tx *gorm.DB) error { +// Watch marks the user to watch the repository. +func (s *RepositoriesStore) Watch(ctx context.Context, userID, repoID int64) error { + return s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { w := &Watch{ UserID: userID, RepoID: repoID, @@ -419,8 +397,9 @@ func (s *reposStore) Watch(ctx context.Context, userID, repoID int64) error { }) } -func (s *reposStore) HasForkedBy(ctx context.Context, repoID, userID int64) bool { +// HasForkedBy returns true if the given repository has forked by the given user. +func (s *RepositoriesStore) HasForkedBy(ctx context.Context, repoID, userID int64) bool { var count int64 - s.WithContext(ctx).Model(new(Repository)).Where("owner_id = ? AND fork_id = ?", userID, repoID).Count(&count) + s.db.WithContext(ctx).Model(new(Repository)).Where("owner_id = ? AND fork_id = ?", userID, repoID).Count(&count) return count > 0 } diff --git a/internal/database/repos_test.go b/internal/database/repositories_test.go similarity index 69% rename from internal/database/repos_test.go rename to internal/database/repositories_test.go index da069460e..69220688d 100644 --- a/internal/database/repos_test.go +++ b/internal/database/repositories_test.go @@ -85,13 +85,13 @@ func TestRepos(t *testing.T) { t.Parallel() ctx := context.Background() - db := &reposStore{ - DB: newTestDB(t, "repos"), + s := &RepositoriesStore{ + db: newTestDB(t, "repos"), } for _, tc := range []struct { name string - test func(t *testing.T, ctx context.Context, db *reposStore) + test func(t *testing.T, ctx context.Context, s *RepositoriesStore) }{ {"Create", reposCreate}, {"GetByCollaboratorID", reposGetByCollaboratorID}, @@ -106,10 +106,10 @@ func TestRepos(t *testing.T) { } { t.Run(tc.name, func(t *testing.T) { t.Cleanup(func() { - err := clearTables(t, db.DB) + err := clearTables(t, s.db) require.NoError(t, err) }) - tc.test(t, ctx, db) + tc.test(t, ctx, s) }) if t.Failed() { break @@ -117,9 +117,9 @@ func TestRepos(t *testing.T) { } } -func reposCreate(t *testing.T, ctx context.Context, db *reposStore) { +func reposCreate(t *testing.T, ctx context.Context, s *RepositoriesStore) { t.Run("name not allowed", func(t *testing.T) { - _, err := db.Create(ctx, + _, err := s.Create(ctx, 1, CreateRepoOptions{ Name: "my.git", @@ -130,14 +130,14 @@ func reposCreate(t *testing.T, ctx context.Context, db *reposStore) { }) t.Run("already exists", func(t *testing.T) { - _, err := db.Create(ctx, 2, + _, err := s.Create(ctx, 2, CreateRepoOptions{ Name: "repo1", }, ) require.NoError(t, err) - _, err = db.Create(ctx, 2, + _, err = s.Create(ctx, 2, CreateRepoOptions{ Name: "repo1", }, @@ -146,54 +146,54 @@ func reposCreate(t *testing.T, ctx context.Context, db *reposStore) { assert.Equal(t, wantErr, err) }) - repo, err := db.Create(ctx, 3, + repo, err := s.Create(ctx, 3, CreateRepoOptions{ Name: "repo2", }, ) require.NoError(t, err) - repo, err = db.GetByName(ctx, repo.OwnerID, repo.Name) + repo, err = s.GetByName(ctx, repo.OwnerID, repo.Name) require.NoError(t, err) - assert.Equal(t, db.NowFunc().Format(time.RFC3339), repo.Created.UTC().Format(time.RFC3339)) + assert.Equal(t, s.db.NowFunc().Format(time.RFC3339), repo.Created.UTC().Format(time.RFC3339)) assert.Equal(t, 1, repo.NumWatches) // The owner is watching the repo by default. } -func reposGetByCollaboratorID(t *testing.T, ctx context.Context, db *reposStore) { - repo1, err := db.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) +func reposGetByCollaboratorID(t *testing.T, ctx context.Context, s *RepositoriesStore) { + repo1, err := s.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) require.NoError(t, err) - repo2, err := db.Create(ctx, 2, CreateRepoOptions{Name: "repo2"}) + repo2, err := s.Create(ctx, 2, CreateRepoOptions{Name: "repo2"}) require.NoError(t, err) - permissionsStore := newPermissionsStore(db.DB) + permissionsStore := newPermissionsStore(s.db) err = permissionsStore.SetRepoPerms(ctx, repo1.ID, map[int64]AccessMode{3: AccessModeRead}) require.NoError(t, err) err = permissionsStore.SetRepoPerms(ctx, repo2.ID, map[int64]AccessMode{4: AccessModeAdmin}) require.NoError(t, err) t.Run("user 3 is a collaborator of repo1", func(t *testing.T) { - got, err := db.GetByCollaboratorID(ctx, 3, 10, "") + got, err := s.GetByCollaboratorID(ctx, 3, 10, "") require.NoError(t, err) require.Len(t, got, 1) assert.Equal(t, repo1.ID, got[0].ID) }) t.Run("do not return directly owned repository", func(t *testing.T) { - got, err := db.GetByCollaboratorID(ctx, 1, 10, "") + got, err := s.GetByCollaboratorID(ctx, 1, 10, "") require.NoError(t, err) require.Len(t, got, 0) }) } -func reposGetByCollaboratorIDWithAccessMode(t *testing.T, ctx context.Context, db *reposStore) { - repo1, err := db.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) +func reposGetByCollaboratorIDWithAccessMode(t *testing.T, ctx context.Context, s *RepositoriesStore) { + repo1, err := s.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) require.NoError(t, err) - repo2, err := db.Create(ctx, 2, CreateRepoOptions{Name: "repo2"}) + repo2, err := s.Create(ctx, 2, CreateRepoOptions{Name: "repo2"}) require.NoError(t, err) - repo3, err := db.Create(ctx, 2, CreateRepoOptions{Name: "repo3"}) + repo3, err := s.Create(ctx, 2, CreateRepoOptions{Name: "repo3"}) require.NoError(t, err) - permissionsStore := newPermissionsStore(db.DB) + permissionsStore := newPermissionsStore(s.db) err = permissionsStore.SetRepoPerms(ctx, repo1.ID, map[int64]AccessMode{3: AccessModeRead}) require.NoError(t, err) err = permissionsStore.SetRepoPerms(ctx, repo2.ID, map[int64]AccessMode{3: AccessModeAdmin, 4: AccessModeWrite}) @@ -201,7 +201,7 @@ func reposGetByCollaboratorIDWithAccessMode(t *testing.T, ctx context.Context, d err = permissionsStore.SetRepoPerms(ctx, repo3.ID, map[int64]AccessMode{4: AccessModeWrite}) require.NoError(t, err) - got, err := db.GetByCollaboratorIDWithAccessMode(ctx, 3) + got, err := s.GetByCollaboratorIDWithAccessMode(ctx, 3) require.NoError(t, err) require.Len(t, got, 2) @@ -213,46 +213,46 @@ func reposGetByCollaboratorIDWithAccessMode(t *testing.T, ctx context.Context, d assert.Equal(t, AccessModeAdmin, accessModes[repo2.ID]) } -func reposGetByID(t *testing.T, ctx context.Context, db *reposStore) { - repo1, err := db.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) +func reposGetByID(t *testing.T, ctx context.Context, s *RepositoriesStore) { + repo1, err := s.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) require.NoError(t, err) - got, err := db.GetByID(ctx, repo1.ID) + got, err := s.GetByID(ctx, repo1.ID) require.NoError(t, err) assert.Equal(t, repo1.Name, got.Name) - _, err = db.GetByID(ctx, 404) + _, err = s.GetByID(ctx, 404) wantErr := ErrRepoNotExist{args: errutil.Args{"repoID": int64(404)}} assert.Equal(t, wantErr, err) } -func reposGetByName(t *testing.T, ctx context.Context, db *reposStore) { - repo, err := db.Create(ctx, 1, +func reposGetByName(t *testing.T, ctx context.Context, s *RepositoriesStore) { + repo, err := s.Create(ctx, 1, CreateRepoOptions{ Name: "repo1", }, ) require.NoError(t, err) - _, err = db.GetByName(ctx, repo.OwnerID, repo.Name) + _, err = s.GetByName(ctx, repo.OwnerID, repo.Name) require.NoError(t, err) - _, err = db.GetByName(ctx, 1, "bad_name") + _, err = s.GetByName(ctx, 1, "bad_name") wantErr := ErrRepoNotExist{args: errutil.Args{"ownerID": int64(1), "name": "bad_name"}} assert.Equal(t, wantErr, err) } -func reposStar(t *testing.T, ctx context.Context, db *reposStore) { - repo1, err := db.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) +func reposStar(t *testing.T, ctx context.Context, s *RepositoriesStore) { + repo1, err := s.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) require.NoError(t, err) - usersStore := NewUsersStore(db.DB) + usersStore := NewUsersStore(s.db) alice, err := usersStore.Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) require.NoError(t, err) - err = db.Star(ctx, alice.ID, repo1.ID) + err = s.Star(ctx, alice.ID, repo1.ID) require.NoError(t, err) - repo1, err = db.GetByID(ctx, repo1.ID) + repo1, err = s.GetByID(ctx, repo1.ID) require.NoError(t, err) assert.Equal(t, 1, repo1.NumStars) @@ -261,41 +261,41 @@ func reposStar(t *testing.T, ctx context.Context, db *reposStore) { assert.Equal(t, 1, alice.NumStars) } -func reposTouch(t *testing.T, ctx context.Context, db *reposStore) { - repo, err := db.Create(ctx, 1, +func reposTouch(t *testing.T, ctx context.Context, s *RepositoriesStore) { + repo, err := s.Create(ctx, 1, CreateRepoOptions{ Name: "repo1", }, ) require.NoError(t, err) - err = db.WithContext(ctx).Model(new(Repository)).Where("id = ?", repo.ID).Update("is_bare", true).Error + err = s.db.WithContext(ctx).Model(new(Repository)).Where("id = ?", repo.ID).Update("is_bare", true).Error require.NoError(t, err) // Make sure it is bare - got, err := db.GetByName(ctx, repo.OwnerID, repo.Name) + got, err := s.GetByName(ctx, repo.OwnerID, repo.Name) require.NoError(t, err) assert.True(t, got.IsBare) // Touch it - err = db.Touch(ctx, repo.ID) + err = s.Touch(ctx, repo.ID) require.NoError(t, err) // It should not be bare anymore - got, err = db.GetByName(ctx, repo.OwnerID, repo.Name) + got, err = s.GetByName(ctx, repo.OwnerID, repo.Name) require.NoError(t, err) assert.False(t, got.IsBare) } -func reposListWatches(t *testing.T, ctx context.Context, db *reposStore) { - err := db.Watch(ctx, 1, 1) +func reposListWatches(t *testing.T, ctx context.Context, s *RepositoriesStore) { + err := s.Watch(ctx, 1, 1) require.NoError(t, err) - err = db.Watch(ctx, 2, 1) + err = s.Watch(ctx, 2, 1) require.NoError(t, err) - err = db.Watch(ctx, 2, 2) + err = s.Watch(ctx, 2, 2) require.NoError(t, err) - got, err := db.ListWatches(ctx, 1) + got, err := s.ListWatches(ctx, 1) require.NoError(t, err) for _, w := range got { w.ID = 0 @@ -308,16 +308,16 @@ func reposListWatches(t *testing.T, ctx context.Context, db *reposStore) { assert.Equal(t, want, got) } -func reposWatch(t *testing.T, ctx context.Context, db *reposStore) { - reposStore := NewReposStore(db.DB) +func reposWatch(t *testing.T, ctx context.Context, s *RepositoriesStore) { + reposStore := newReposStore(s.db) repo1, err := reposStore.Create(ctx, 1, CreateRepoOptions{Name: "repo1"}) require.NoError(t, err) - err = db.Watch(ctx, 2, repo1.ID) + err = s.Watch(ctx, 2, repo1.ID) require.NoError(t, err) // It is OK to watch multiple times and just be noop. - err = db.Watch(ctx, 2, repo1.ID) + err = s.Watch(ctx, 2, repo1.ID) require.NoError(t, err) repo1, err = reposStore.GetByID(ctx, repo1.ID) @@ -325,11 +325,11 @@ func reposWatch(t *testing.T, ctx context.Context, db *reposStore) { assert.Equal(t, 2, repo1.NumWatches) // The owner is watching the repo by default. } -func reposHasForkedBy(t *testing.T, ctx context.Context, db *reposStore) { - has := db.HasForkedBy(ctx, 1, 2) +func reposHasForkedBy(t *testing.T, ctx context.Context, s *RepositoriesStore) { + has := s.HasForkedBy(ctx, 1, 2) assert.False(t, has) - _, err := NewReposStore(db.DB).Create( + _, err := newReposStore(s.db).Create( ctx, 2, CreateRepoOptions{ @@ -339,6 +339,6 @@ func reposHasForkedBy(t *testing.T, ctx context.Context, db *reposStore) { ) require.NoError(t, err) - has = db.HasForkedBy(ctx, 1, 2) + has = s.HasForkedBy(ctx, 1, 2) assert.True(t, has) } diff --git a/internal/database/users_test.go b/internal/database/users_test.go index f4231f090..a874d90da 100644 --- a/internal/database/users_test.go +++ b/internal/database/users_test.go @@ -294,7 +294,7 @@ func usersChangeUsername(t *testing.T, ctx context.Context, db *usersStore) { require.NoError(t, err) defer func() { _ = os.RemoveAll(tempServerAppDataPath) }() - repo, err := NewReposStore(db.DB).Create( + repo, err := newReposStore(db.DB).Create( ctx, alice.ID, CreateRepoOptions{ @@ -466,7 +466,7 @@ func usersDeleteCustomAvatar(t *testing.T, ctx context.Context, db *usersStore) } func usersDeleteByID(t *testing.T, ctx context.Context, db *usersStore) { - reposStore := NewReposStore(db.DB) + reposStore := newReposStore(db.DB) t.Run("user still has repository ownership", func(t *testing.T) { alice, err := db.Create(ctx, "alice", "alice@exmaple.com", CreateUserOptions{}) @@ -679,7 +679,7 @@ func usersDeleteInactivated(t *testing.T, ctx context.Context, db *usersStore) { // User with repository ownership should be skipped alice, err := db.Create(ctx, "alice", "alice@exmaple.com", CreateUserOptions{}) require.NoError(t, err) - reposStore := NewReposStore(db.DB) + reposStore := newReposStore(db.DB) _, err = reposStore.Create(ctx, alice.ID, CreateRepoOptions{Name: "repo1"}) require.NoError(t, err) diff --git a/internal/route/api/v1/api.go b/internal/route/api/v1/api.go index 8c355d12a..663abebf9 100644 --- a/internal/route/api/v1/api.go +++ b/internal/route/api/v1/api.go @@ -45,7 +45,7 @@ func repoAssignment() macaron.Handler { } c.Repo.Owner = owner - repo, err := database.Repos.GetByName(c.Req.Context(), owner.ID, reponame) + repo, err := database.Handle.Repositories().GetByName(c.Req.Context(), owner.ID, reponame) if err != nil { c.NotFoundOrError(err, "get repository by name") return diff --git a/internal/route/api/v1/repo/repo.go b/internal/route/api/v1/repo/repo.go index d5b1f5848..950593224 100644 --- a/internal/route/api/v1/repo/repo.go +++ b/internal/route/api/v1/repo/repo.go @@ -116,7 +116,7 @@ func listUserRepositories(c *context.APIContext, username string) { return } - accessibleRepos, err := database.Repos.GetByCollaboratorIDWithAccessMode(c.Req.Context(), user.ID) + accessibleRepos, err := database.Handle.Repositories().GetByCollaboratorIDWithAccessMode(c.Req.Context(), user.ID) if err != nil { c.Error(err, "get repositories accesses by collaborator") return diff --git a/internal/route/lfs/mocks_test.go b/internal/route/lfs/mocks_test.go index b028fd66d..b8a75491d 100644 --- a/internal/route/lfs/mocks_test.go +++ b/internal/route/lfs/mocks_test.go @@ -14,1284 +14,6 @@ import ( lfsutil "gogs.io/gogs/internal/lfsutil" ) -// MockReposStore is a mock implementation of the ReposStore interface (from -// the package gogs.io/gogs/internal/database) used for unit testing. -type MockReposStore struct { - // CreateFunc is an instance of a mock function object controlling the - // behavior of the method Create. - CreateFunc *ReposStoreCreateFunc - // GetByCollaboratorIDFunc is an instance of a mock function object - // controlling the behavior of the method GetByCollaboratorID. - GetByCollaboratorIDFunc *ReposStoreGetByCollaboratorIDFunc - // GetByCollaboratorIDWithAccessModeFunc is an instance of a mock - // function object controlling the behavior of the method - // GetByCollaboratorIDWithAccessMode. - GetByCollaboratorIDWithAccessModeFunc *ReposStoreGetByCollaboratorIDWithAccessModeFunc - // GetByIDFunc is an instance of a mock function object controlling the - // behavior of the method GetByID. - GetByIDFunc *ReposStoreGetByIDFunc - // GetByNameFunc is an instance of a mock function object controlling - // the behavior of the method GetByName. - GetByNameFunc *ReposStoreGetByNameFunc - // HasForkedByFunc is an instance of a mock function object controlling - // the behavior of the method HasForkedBy. - HasForkedByFunc *ReposStoreHasForkedByFunc - // ListWatchesFunc is an instance of a mock function object controlling - // the behavior of the method ListWatches. - ListWatchesFunc *ReposStoreListWatchesFunc - // StarFunc is an instance of a mock function object controlling the - // behavior of the method Star. - StarFunc *ReposStoreStarFunc - // TouchFunc is an instance of a mock function object controlling the - // behavior of the method Touch. - TouchFunc *ReposStoreTouchFunc - // WatchFunc is an instance of a mock function object controlling the - // behavior of the method Watch. - WatchFunc *ReposStoreWatchFunc -} - -// NewMockReposStore creates a new mock of the ReposStore interface. All -// methods return zero values for all results, unless overwritten. -func NewMockReposStore() *MockReposStore { - return &MockReposStore{ - CreateFunc: &ReposStoreCreateFunc{ - defaultHook: func(context.Context, int64, database.CreateRepoOptions) (r0 *database.Repository, r1 error) { - return - }, - }, - GetByCollaboratorIDFunc: &ReposStoreGetByCollaboratorIDFunc{ - defaultHook: func(context.Context, int64, int, string) (r0 []*database.Repository, r1 error) { - return - }, - }, - GetByCollaboratorIDWithAccessModeFunc: &ReposStoreGetByCollaboratorIDWithAccessModeFunc{ - defaultHook: func(context.Context, int64) (r0 map[*database.Repository]database.AccessMode, r1 error) { - return - }, - }, - GetByIDFunc: &ReposStoreGetByIDFunc{ - defaultHook: func(context.Context, int64) (r0 *database.Repository, r1 error) { - return - }, - }, - GetByNameFunc: &ReposStoreGetByNameFunc{ - defaultHook: func(context.Context, int64, string) (r0 *database.Repository, r1 error) { - return - }, - }, - HasForkedByFunc: &ReposStoreHasForkedByFunc{ - defaultHook: func(context.Context, int64, int64) (r0 bool) { - return - }, - }, - ListWatchesFunc: &ReposStoreListWatchesFunc{ - defaultHook: func(context.Context, int64) (r0 []*database.Watch, r1 error) { - return - }, - }, - StarFunc: &ReposStoreStarFunc{ - defaultHook: func(context.Context, int64, int64) (r0 error) { - return - }, - }, - TouchFunc: &ReposStoreTouchFunc{ - defaultHook: func(context.Context, int64) (r0 error) { - return - }, - }, - WatchFunc: &ReposStoreWatchFunc{ - defaultHook: func(context.Context, int64, int64) (r0 error) { - return - }, - }, - } -} - -// NewStrictMockReposStore creates a new mock of the ReposStore interface. -// All methods panic on invocation, unless overwritten. -func NewStrictMockReposStore() *MockReposStore { - return &MockReposStore{ - CreateFunc: &ReposStoreCreateFunc{ - defaultHook: func(context.Context, int64, database.CreateRepoOptions) (*database.Repository, error) { - panic("unexpected invocation of MockReposStore.Create") - }, - }, - GetByCollaboratorIDFunc: &ReposStoreGetByCollaboratorIDFunc{ - defaultHook: func(context.Context, int64, int, string) ([]*database.Repository, error) { - panic("unexpected invocation of MockReposStore.GetByCollaboratorID") - }, - }, - GetByCollaboratorIDWithAccessModeFunc: &ReposStoreGetByCollaboratorIDWithAccessModeFunc{ - defaultHook: func(context.Context, int64) (map[*database.Repository]database.AccessMode, error) { - panic("unexpected invocation of MockReposStore.GetByCollaboratorIDWithAccessMode") - }, - }, - GetByIDFunc: &ReposStoreGetByIDFunc{ - defaultHook: func(context.Context, int64) (*database.Repository, error) { - panic("unexpected invocation of MockReposStore.GetByID") - }, - }, - GetByNameFunc: &ReposStoreGetByNameFunc{ - defaultHook: func(context.Context, int64, string) (*database.Repository, error) { - panic("unexpected invocation of MockReposStore.GetByName") - }, - }, - HasForkedByFunc: &ReposStoreHasForkedByFunc{ - defaultHook: func(context.Context, int64, int64) bool { - panic("unexpected invocation of MockReposStore.HasForkedBy") - }, - }, - ListWatchesFunc: &ReposStoreListWatchesFunc{ - defaultHook: func(context.Context, int64) ([]*database.Watch, error) { - panic("unexpected invocation of MockReposStore.ListWatches") - }, - }, - StarFunc: &ReposStoreStarFunc{ - defaultHook: func(context.Context, int64, int64) error { - panic("unexpected invocation of MockReposStore.Star") - }, - }, - TouchFunc: &ReposStoreTouchFunc{ - defaultHook: func(context.Context, int64) error { - panic("unexpected invocation of MockReposStore.Touch") - }, - }, - WatchFunc: &ReposStoreWatchFunc{ - defaultHook: func(context.Context, int64, int64) error { - panic("unexpected invocation of MockReposStore.Watch") - }, - }, - } -} - -// NewMockReposStoreFrom creates a new mock of the MockReposStore interface. -// All methods delegate to the given implementation, unless overwritten. -func NewMockReposStoreFrom(i database.ReposStore) *MockReposStore { - return &MockReposStore{ - CreateFunc: &ReposStoreCreateFunc{ - defaultHook: i.Create, - }, - GetByCollaboratorIDFunc: &ReposStoreGetByCollaboratorIDFunc{ - defaultHook: i.GetByCollaboratorID, - }, - GetByCollaboratorIDWithAccessModeFunc: &ReposStoreGetByCollaboratorIDWithAccessModeFunc{ - defaultHook: i.GetByCollaboratorIDWithAccessMode, - }, - GetByIDFunc: &ReposStoreGetByIDFunc{ - defaultHook: i.GetByID, - }, - GetByNameFunc: &ReposStoreGetByNameFunc{ - defaultHook: i.GetByName, - }, - HasForkedByFunc: &ReposStoreHasForkedByFunc{ - defaultHook: i.HasForkedBy, - }, - ListWatchesFunc: &ReposStoreListWatchesFunc{ - defaultHook: i.ListWatches, - }, - StarFunc: &ReposStoreStarFunc{ - defaultHook: i.Star, - }, - TouchFunc: &ReposStoreTouchFunc{ - defaultHook: i.Touch, - }, - WatchFunc: &ReposStoreWatchFunc{ - defaultHook: i.Watch, - }, - } -} - -// ReposStoreCreateFunc describes the behavior when the Create method of the -// parent MockReposStore instance is invoked. -type ReposStoreCreateFunc struct { - defaultHook func(context.Context, int64, database.CreateRepoOptions) (*database.Repository, error) - hooks []func(context.Context, int64, database.CreateRepoOptions) (*database.Repository, error) - history []ReposStoreCreateFuncCall - mutex sync.Mutex -} - -// Create delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockReposStore) Create(v0 context.Context, v1 int64, v2 database.CreateRepoOptions) (*database.Repository, error) { - r0, r1 := m.CreateFunc.nextHook()(v0, v1, v2) - m.CreateFunc.appendCall(ReposStoreCreateFuncCall{v0, v1, v2, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the Create method of the -// parent MockReposStore instance is invoked and the hook queue is empty. -func (f *ReposStoreCreateFunc) SetDefaultHook(hook func(context.Context, int64, database.CreateRepoOptions) (*database.Repository, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Create 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 *ReposStoreCreateFunc) PushHook(hook func(context.Context, int64, database.CreateRepoOptions) (*database.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 *ReposStoreCreateFunc) SetDefaultReturn(r0 *database.Repository, r1 error) { - f.SetDefaultHook(func(context.Context, int64, database.CreateRepoOptions) (*database.Repository, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreCreateFunc) PushReturn(r0 *database.Repository, r1 error) { - f.PushHook(func(context.Context, int64, database.CreateRepoOptions) (*database.Repository, error) { - return r0, r1 - }) -} - -func (f *ReposStoreCreateFunc) nextHook() func(context.Context, int64, database.CreateRepoOptions) (*database.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 *ReposStoreCreateFunc) appendCall(r0 ReposStoreCreateFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of ReposStoreCreateFuncCall objects describing -// the invocations of this function. -func (f *ReposStoreCreateFunc) History() []ReposStoreCreateFuncCall { - f.mutex.Lock() - history := make([]ReposStoreCreateFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreCreateFuncCall is an object that describes an invocation of -// method Create on an instance of MockReposStore. -type ReposStoreCreateFuncCall 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 database.CreateRepoOptions - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *database.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 ReposStoreCreateFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreCreateFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// ReposStoreGetByCollaboratorIDFunc describes the behavior when the -// GetByCollaboratorID method of the parent MockReposStore instance is -// invoked. -type ReposStoreGetByCollaboratorIDFunc struct { - defaultHook func(context.Context, int64, int, string) ([]*database.Repository, error) - hooks []func(context.Context, int64, int, string) ([]*database.Repository, error) - history []ReposStoreGetByCollaboratorIDFuncCall - mutex sync.Mutex -} - -// GetByCollaboratorID delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockReposStore) GetByCollaboratorID(v0 context.Context, v1 int64, v2 int, v3 string) ([]*database.Repository, error) { - r0, r1 := m.GetByCollaboratorIDFunc.nextHook()(v0, v1, v2, v3) - m.GetByCollaboratorIDFunc.appendCall(ReposStoreGetByCollaboratorIDFuncCall{v0, v1, v2, v3, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the GetByCollaboratorID -// method of the parent MockReposStore instance is invoked and the hook -// queue is empty. -func (f *ReposStoreGetByCollaboratorIDFunc) SetDefaultHook(hook func(context.Context, int64, int, string) ([]*database.Repository, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetByCollaboratorID 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 *ReposStoreGetByCollaboratorIDFunc) PushHook(hook func(context.Context, int64, int, string) ([]*database.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 *ReposStoreGetByCollaboratorIDFunc) SetDefaultReturn(r0 []*database.Repository, r1 error) { - f.SetDefaultHook(func(context.Context, int64, int, string) ([]*database.Repository, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreGetByCollaboratorIDFunc) PushReturn(r0 []*database.Repository, r1 error) { - f.PushHook(func(context.Context, int64, int, string) ([]*database.Repository, error) { - return r0, r1 - }) -} - -func (f *ReposStoreGetByCollaboratorIDFunc) nextHook() func(context.Context, int64, int, string) ([]*database.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 *ReposStoreGetByCollaboratorIDFunc) appendCall(r0 ReposStoreGetByCollaboratorIDFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of ReposStoreGetByCollaboratorIDFuncCall -// objects describing the invocations of this function. -func (f *ReposStoreGetByCollaboratorIDFunc) History() []ReposStoreGetByCollaboratorIDFuncCall { - f.mutex.Lock() - history := make([]ReposStoreGetByCollaboratorIDFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreGetByCollaboratorIDFuncCall is an object that describes an -// invocation of method GetByCollaboratorID on an instance of -// MockReposStore. -type ReposStoreGetByCollaboratorIDFuncCall 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 int - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 []*database.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 ReposStoreGetByCollaboratorIDFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreGetByCollaboratorIDFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// ReposStoreGetByCollaboratorIDWithAccessModeFunc describes the behavior -// when the GetByCollaboratorIDWithAccessMode method of the parent -// MockReposStore instance is invoked. -type ReposStoreGetByCollaboratorIDWithAccessModeFunc struct { - defaultHook func(context.Context, int64) (map[*database.Repository]database.AccessMode, error) - hooks []func(context.Context, int64) (map[*database.Repository]database.AccessMode, error) - history []ReposStoreGetByCollaboratorIDWithAccessModeFuncCall - mutex sync.Mutex -} - -// GetByCollaboratorIDWithAccessMode delegates to the next hook function in -// the queue and stores the parameter and result values of this invocation. -func (m *MockReposStore) GetByCollaboratorIDWithAccessMode(v0 context.Context, v1 int64) (map[*database.Repository]database.AccessMode, error) { - r0, r1 := m.GetByCollaboratorIDWithAccessModeFunc.nextHook()(v0, v1) - m.GetByCollaboratorIDWithAccessModeFunc.appendCall(ReposStoreGetByCollaboratorIDWithAccessModeFuncCall{v0, v1, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the -// GetByCollaboratorIDWithAccessMode method of the parent MockReposStore -// instance is invoked and the hook queue is empty. -func (f *ReposStoreGetByCollaboratorIDWithAccessModeFunc) SetDefaultHook(hook func(context.Context, int64) (map[*database.Repository]database.AccessMode, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetByCollaboratorIDWithAccessMode 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 *ReposStoreGetByCollaboratorIDWithAccessModeFunc) PushHook(hook func(context.Context, int64) (map[*database.Repository]database.AccessMode, 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 *ReposStoreGetByCollaboratorIDWithAccessModeFunc) SetDefaultReturn(r0 map[*database.Repository]database.AccessMode, r1 error) { - f.SetDefaultHook(func(context.Context, int64) (map[*database.Repository]database.AccessMode, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreGetByCollaboratorIDWithAccessModeFunc) PushReturn(r0 map[*database.Repository]database.AccessMode, r1 error) { - f.PushHook(func(context.Context, int64) (map[*database.Repository]database.AccessMode, error) { - return r0, r1 - }) -} - -func (f *ReposStoreGetByCollaboratorIDWithAccessModeFunc) nextHook() func(context.Context, int64) (map[*database.Repository]database.AccessMode, 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 *ReposStoreGetByCollaboratorIDWithAccessModeFunc) appendCall(r0 ReposStoreGetByCollaboratorIDWithAccessModeFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of -// ReposStoreGetByCollaboratorIDWithAccessModeFuncCall objects describing -// the invocations of this function. -func (f *ReposStoreGetByCollaboratorIDWithAccessModeFunc) History() []ReposStoreGetByCollaboratorIDWithAccessModeFuncCall { - f.mutex.Lock() - history := make([]ReposStoreGetByCollaboratorIDWithAccessModeFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreGetByCollaboratorIDWithAccessModeFuncCall is an object that -// describes an invocation of method GetByCollaboratorIDWithAccessMode on an -// instance of MockReposStore. -type ReposStoreGetByCollaboratorIDWithAccessModeFuncCall 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 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 map[*database.Repository]database.AccessMode - // 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 ReposStoreGetByCollaboratorIDWithAccessModeFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreGetByCollaboratorIDWithAccessModeFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// ReposStoreGetByIDFunc describes the behavior when the GetByID method of -// the parent MockReposStore instance is invoked. -type ReposStoreGetByIDFunc struct { - defaultHook func(context.Context, int64) (*database.Repository, error) - hooks []func(context.Context, int64) (*database.Repository, error) - history []ReposStoreGetByIDFuncCall - mutex sync.Mutex -} - -// GetByID delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockReposStore) GetByID(v0 context.Context, v1 int64) (*database.Repository, error) { - r0, r1 := m.GetByIDFunc.nextHook()(v0, v1) - m.GetByIDFunc.appendCall(ReposStoreGetByIDFuncCall{v0, v1, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the GetByID method of -// the parent MockReposStore instance is invoked and the hook queue is -// empty. -func (f *ReposStoreGetByIDFunc) SetDefaultHook(hook func(context.Context, int64) (*database.Repository, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetByID 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 *ReposStoreGetByIDFunc) PushHook(hook func(context.Context, int64) (*database.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 *ReposStoreGetByIDFunc) SetDefaultReturn(r0 *database.Repository, r1 error) { - f.SetDefaultHook(func(context.Context, int64) (*database.Repository, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreGetByIDFunc) PushReturn(r0 *database.Repository, r1 error) { - f.PushHook(func(context.Context, int64) (*database.Repository, error) { - return r0, r1 - }) -} - -func (f *ReposStoreGetByIDFunc) nextHook() func(context.Context, int64) (*database.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 *ReposStoreGetByIDFunc) appendCall(r0 ReposStoreGetByIDFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of ReposStoreGetByIDFuncCall objects -// describing the invocations of this function. -func (f *ReposStoreGetByIDFunc) History() []ReposStoreGetByIDFuncCall { - f.mutex.Lock() - history := make([]ReposStoreGetByIDFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreGetByIDFuncCall is an object that describes an invocation of -// method GetByID on an instance of MockReposStore. -type ReposStoreGetByIDFuncCall 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 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *database.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 ReposStoreGetByIDFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreGetByIDFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// ReposStoreGetByNameFunc describes the behavior when the GetByName method -// of the parent MockReposStore instance is invoked. -type ReposStoreGetByNameFunc struct { - defaultHook func(context.Context, int64, string) (*database.Repository, error) - hooks []func(context.Context, int64, string) (*database.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) (*database.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) (*database.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) (*database.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 *database.Repository, r1 error) { - f.SetDefaultHook(func(context.Context, int64, string) (*database.Repository, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreGetByNameFunc) PushReturn(r0 *database.Repository, r1 error) { - f.PushHook(func(context.Context, int64, string) (*database.Repository, error) { - return r0, r1 - }) -} - -func (f *ReposStoreGetByNameFunc) nextHook() func(context.Context, int64, string) (*database.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 *database.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} -} - -// ReposStoreHasForkedByFunc describes the behavior when the HasForkedBy -// method of the parent MockReposStore instance is invoked. -type ReposStoreHasForkedByFunc struct { - defaultHook func(context.Context, int64, int64) bool - hooks []func(context.Context, int64, int64) bool - history []ReposStoreHasForkedByFuncCall - mutex sync.Mutex -} - -// HasForkedBy delegates to the next hook function in the queue and stores -// the parameter and result values of this invocation. -func (m *MockReposStore) HasForkedBy(v0 context.Context, v1 int64, v2 int64) bool { - r0 := m.HasForkedByFunc.nextHook()(v0, v1, v2) - m.HasForkedByFunc.appendCall(ReposStoreHasForkedByFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the HasForkedBy method -// of the parent MockReposStore instance is invoked and the hook queue is -// empty. -func (f *ReposStoreHasForkedByFunc) SetDefaultHook(hook func(context.Context, int64, int64) bool) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// HasForkedBy 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 *ReposStoreHasForkedByFunc) PushHook(hook func(context.Context, int64, int64) bool) { - 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 *ReposStoreHasForkedByFunc) SetDefaultReturn(r0 bool) { - f.SetDefaultHook(func(context.Context, int64, int64) bool { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreHasForkedByFunc) PushReturn(r0 bool) { - f.PushHook(func(context.Context, int64, int64) bool { - return r0 - }) -} - -func (f *ReposStoreHasForkedByFunc) nextHook() func(context.Context, int64, int64) bool { - 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 *ReposStoreHasForkedByFunc) appendCall(r0 ReposStoreHasForkedByFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of ReposStoreHasForkedByFuncCall objects -// describing the invocations of this function. -func (f *ReposStoreHasForkedByFunc) History() []ReposStoreHasForkedByFuncCall { - f.mutex.Lock() - history := make([]ReposStoreHasForkedByFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreHasForkedByFuncCall is an object that describes an invocation -// of method HasForkedBy on an instance of MockReposStore. -type ReposStoreHasForkedByFuncCall 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 int64 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 bool -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c ReposStoreHasForkedByFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreHasForkedByFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// ReposStoreListWatchesFunc describes the behavior when the ListWatches -// method of the parent MockReposStore instance is invoked. -type ReposStoreListWatchesFunc struct { - defaultHook func(context.Context, int64) ([]*database.Watch, error) - hooks []func(context.Context, int64) ([]*database.Watch, error) - history []ReposStoreListWatchesFuncCall - mutex sync.Mutex -} - -// ListWatches delegates to the next hook function in the queue and stores -// the parameter and result values of this invocation. -func (m *MockReposStore) ListWatches(v0 context.Context, v1 int64) ([]*database.Watch, error) { - r0, r1 := m.ListWatchesFunc.nextHook()(v0, v1) - m.ListWatchesFunc.appendCall(ReposStoreListWatchesFuncCall{v0, v1, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the ListWatches method -// of the parent MockReposStore instance is invoked and the hook queue is -// empty. -func (f *ReposStoreListWatchesFunc) SetDefaultHook(hook func(context.Context, int64) ([]*database.Watch, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ListWatches 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 *ReposStoreListWatchesFunc) PushHook(hook func(context.Context, int64) ([]*database.Watch, 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 *ReposStoreListWatchesFunc) SetDefaultReturn(r0 []*database.Watch, r1 error) { - f.SetDefaultHook(func(context.Context, int64) ([]*database.Watch, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreListWatchesFunc) PushReturn(r0 []*database.Watch, r1 error) { - f.PushHook(func(context.Context, int64) ([]*database.Watch, error) { - return r0, r1 - }) -} - -func (f *ReposStoreListWatchesFunc) nextHook() func(context.Context, int64) ([]*database.Watch, 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 *ReposStoreListWatchesFunc) appendCall(r0 ReposStoreListWatchesFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of ReposStoreListWatchesFuncCall objects -// describing the invocations of this function. -func (f *ReposStoreListWatchesFunc) History() []ReposStoreListWatchesFuncCall { - f.mutex.Lock() - history := make([]ReposStoreListWatchesFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreListWatchesFuncCall is an object that describes an invocation -// of method ListWatches on an instance of MockReposStore. -type ReposStoreListWatchesFuncCall 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 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 []*database.Watch - // 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 ReposStoreListWatchesFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreListWatchesFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// ReposStoreStarFunc describes the behavior when the Star method of the -// parent MockReposStore instance is invoked. -type ReposStoreStarFunc struct { - defaultHook func(context.Context, int64, int64) error - hooks []func(context.Context, int64, int64) error - history []ReposStoreStarFuncCall - mutex sync.Mutex -} - -// Star delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockReposStore) Star(v0 context.Context, v1 int64, v2 int64) error { - r0 := m.StarFunc.nextHook()(v0, v1, v2) - m.StarFunc.appendCall(ReposStoreStarFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Star method of the -// parent MockReposStore instance is invoked and the hook queue is empty. -func (f *ReposStoreStarFunc) SetDefaultHook(hook func(context.Context, int64, int64) error) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Star 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 *ReposStoreStarFunc) PushHook(hook func(context.Context, int64, int64) 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 *ReposStoreStarFunc) SetDefaultReturn(r0 error) { - f.SetDefaultHook(func(context.Context, int64, int64) error { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreStarFunc) PushReturn(r0 error) { - f.PushHook(func(context.Context, int64, int64) error { - return r0 - }) -} - -func (f *ReposStoreStarFunc) nextHook() func(context.Context, int64, int64) 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 *ReposStoreStarFunc) appendCall(r0 ReposStoreStarFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of ReposStoreStarFuncCall objects describing -// the invocations of this function. -func (f *ReposStoreStarFunc) History() []ReposStoreStarFuncCall { - f.mutex.Lock() - history := make([]ReposStoreStarFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreStarFuncCall is an object that describes an invocation of -// method Star on an instance of MockReposStore. -type ReposStoreStarFuncCall 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 int64 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c ReposStoreStarFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreStarFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// ReposStoreTouchFunc describes the behavior when the Touch method of the -// parent MockReposStore instance is invoked. -type ReposStoreTouchFunc struct { - defaultHook func(context.Context, int64) error - hooks []func(context.Context, int64) error - history []ReposStoreTouchFuncCall - mutex sync.Mutex -} - -// Touch delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockReposStore) Touch(v0 context.Context, v1 int64) error { - r0 := m.TouchFunc.nextHook()(v0, v1) - m.TouchFunc.appendCall(ReposStoreTouchFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Touch method of the -// parent MockReposStore instance is invoked and the hook queue is empty. -func (f *ReposStoreTouchFunc) SetDefaultHook(hook func(context.Context, int64) error) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Touch 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 *ReposStoreTouchFunc) PushHook(hook func(context.Context, int64) 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 *ReposStoreTouchFunc) SetDefaultReturn(r0 error) { - f.SetDefaultHook(func(context.Context, int64) error { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreTouchFunc) PushReturn(r0 error) { - f.PushHook(func(context.Context, int64) error { - return r0 - }) -} - -func (f *ReposStoreTouchFunc) nextHook() func(context.Context, int64) 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 *ReposStoreTouchFunc) appendCall(r0 ReposStoreTouchFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of ReposStoreTouchFuncCall objects describing -// the invocations of this function. -func (f *ReposStoreTouchFunc) History() []ReposStoreTouchFuncCall { - f.mutex.Lock() - history := make([]ReposStoreTouchFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreTouchFuncCall is an object that describes an invocation of -// method Touch on an instance of MockReposStore. -type ReposStoreTouchFuncCall 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 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c ReposStoreTouchFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreTouchFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// ReposStoreWatchFunc describes the behavior when the Watch method of the -// parent MockReposStore instance is invoked. -type ReposStoreWatchFunc struct { - defaultHook func(context.Context, int64, int64) error - hooks []func(context.Context, int64, int64) error - history []ReposStoreWatchFuncCall - mutex sync.Mutex -} - -// Watch delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockReposStore) Watch(v0 context.Context, v1 int64, v2 int64) error { - r0 := m.WatchFunc.nextHook()(v0, v1, v2) - m.WatchFunc.appendCall(ReposStoreWatchFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Watch method of the -// parent MockReposStore instance is invoked and the hook queue is empty. -func (f *ReposStoreWatchFunc) SetDefaultHook(hook func(context.Context, int64, int64) error) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Watch 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 *ReposStoreWatchFunc) PushHook(hook func(context.Context, int64, int64) 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 *ReposStoreWatchFunc) SetDefaultReturn(r0 error) { - f.SetDefaultHook(func(context.Context, int64, int64) error { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *ReposStoreWatchFunc) PushReturn(r0 error) { - f.PushHook(func(context.Context, int64, int64) error { - return r0 - }) -} - -func (f *ReposStoreWatchFunc) nextHook() func(context.Context, int64, int64) 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 *ReposStoreWatchFunc) appendCall(r0 ReposStoreWatchFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of ReposStoreWatchFuncCall objects describing -// the invocations of this function. -func (f *ReposStoreWatchFunc) History() []ReposStoreWatchFuncCall { - f.mutex.Lock() - history := make([]ReposStoreWatchFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// ReposStoreWatchFuncCall is an object that describes an invocation of -// method Watch on an instance of MockReposStore. -type ReposStoreWatchFuncCall 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 int64 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c ReposStoreWatchFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c ReposStoreWatchFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - // MockTwoFactorsStore is a mock implementation of the TwoFactorsStore // interface (from the package gogs.io/gogs/internal/database) used for unit // testing. @@ -5243,6 +3965,9 @@ type MockStore struct { // GetLFSObjectsByOIDsFunc is an instance of a mock function object // controlling the behavior of the method GetLFSObjectsByOIDs. GetLFSObjectsByOIDsFunc *StoreGetLFSObjectsByOIDsFunc + // GetRepositoryByNameFunc is an instance of a mock function object + // controlling the behavior of the method GetRepositoryByName. + GetRepositoryByNameFunc *StoreGetRepositoryByNameFunc // TouchAccessTokenByIDFunc is an instance of a mock function object // controlling the behavior of the method TouchAccessTokenByID. TouchAccessTokenByIDFunc *StoreTouchAccessTokenByIDFunc @@ -5277,6 +4002,11 @@ func NewMockStore() *MockStore { return }, }, + GetRepositoryByNameFunc: &StoreGetRepositoryByNameFunc{ + defaultHook: func(context.Context, int64, string) (r0 *database.Repository, r1 error) { + return + }, + }, TouchAccessTokenByIDFunc: &StoreTouchAccessTokenByIDFunc{ defaultHook: func(context.Context, int64) (r0 error) { return @@ -5314,6 +4044,11 @@ func NewStrictMockStore() *MockStore { panic("unexpected invocation of MockStore.GetLFSObjectsByOIDs") }, }, + GetRepositoryByNameFunc: &StoreGetRepositoryByNameFunc{ + defaultHook: func(context.Context, int64, string) (*database.Repository, error) { + panic("unexpected invocation of MockStore.GetRepositoryByName") + }, + }, TouchAccessTokenByIDFunc: &StoreTouchAccessTokenByIDFunc{ defaultHook: func(context.Context, int64) error { panic("unexpected invocation of MockStore.TouchAccessTokenByID") @@ -5341,6 +4076,9 @@ func NewMockStoreFrom(i Store) *MockStore { GetLFSObjectsByOIDsFunc: &StoreGetLFSObjectsByOIDsFunc{ defaultHook: i.GetLFSObjectsByOIDs, }, + GetRepositoryByNameFunc: &StoreGetRepositoryByNameFunc{ + defaultHook: i.GetRepositoryByName, + }, TouchAccessTokenByIDFunc: &StoreTouchAccessTokenByIDFunc{ defaultHook: i.TouchAccessTokenByID, }, @@ -5914,6 +4652,117 @@ func (c StoreGetLFSObjectsByOIDsFuncCall) Results() []interface{} { return []interface{}{c.Result0, c.Result1} } +// StoreGetRepositoryByNameFunc describes the behavior when the +// GetRepositoryByName method of the parent MockStore instance is invoked. +type StoreGetRepositoryByNameFunc struct { + defaultHook func(context.Context, int64, string) (*database.Repository, error) + hooks []func(context.Context, int64, string) (*database.Repository, error) + history []StoreGetRepositoryByNameFuncCall + mutex sync.Mutex +} + +// GetRepositoryByName delegates to the next hook function in the queue and +// stores the parameter and result values of this invocation. +func (m *MockStore) GetRepositoryByName(v0 context.Context, v1 int64, v2 string) (*database.Repository, error) { + r0, r1 := m.GetRepositoryByNameFunc.nextHook()(v0, v1, v2) + m.GetRepositoryByNameFunc.appendCall(StoreGetRepositoryByNameFuncCall{v0, v1, v2, r0, r1}) + return r0, r1 +} + +// SetDefaultHook sets function that is called when the GetRepositoryByName +// method of the parent MockStore instance is invoked and the hook queue is +// empty. +func (f *StoreGetRepositoryByNameFunc) SetDefaultHook(hook func(context.Context, int64, string) (*database.Repository, error)) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// GetRepositoryByName method of the parent MockStore 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 *StoreGetRepositoryByNameFunc) PushHook(hook func(context.Context, int64, string) (*database.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 *StoreGetRepositoryByNameFunc) SetDefaultReturn(r0 *database.Repository, r1 error) { + f.SetDefaultHook(func(context.Context, int64, string) (*database.Repository, error) { + return r0, r1 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *StoreGetRepositoryByNameFunc) PushReturn(r0 *database.Repository, r1 error) { + f.PushHook(func(context.Context, int64, string) (*database.Repository, error) { + return r0, r1 + }) +} + +func (f *StoreGetRepositoryByNameFunc) nextHook() func(context.Context, int64, string) (*database.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 *StoreGetRepositoryByNameFunc) appendCall(r0 StoreGetRepositoryByNameFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of StoreGetRepositoryByNameFuncCall objects +// describing the invocations of this function. +func (f *StoreGetRepositoryByNameFunc) History() []StoreGetRepositoryByNameFuncCall { + f.mutex.Lock() + history := make([]StoreGetRepositoryByNameFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// StoreGetRepositoryByNameFuncCall is an object that describes an +// invocation of method GetRepositoryByName on an instance of MockStore. +type StoreGetRepositoryByNameFuncCall 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 *database.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 StoreGetRepositoryByNameFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1, c.Arg2} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c StoreGetRepositoryByNameFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1} +} + // StoreTouchAccessTokenByIDFunc describes the behavior when the // TouchAccessTokenByID method of the parent MockStore instance is invoked. type StoreTouchAccessTokenByIDFunc struct { diff --git a/internal/route/lfs/route.go b/internal/route/lfs/route.go index 21e5b0f41..1176830f8 100644 --- a/internal/route/lfs/route.go +++ b/internal/route/lfs/route.go @@ -120,7 +120,7 @@ func authorize(store Store, mode database.AccessMode) macaron.Handler { return } - repo, err := database.Repos.GetByName(c.Req.Context(), owner.ID, reponame) + repo, err := store.GetRepositoryByName(c.Req.Context(), owner.ID, reponame) if err != nil { if database.IsErrRepoNotExist(err) { c.Status(http.StatusNotFound) diff --git a/internal/route/lfs/route_test.go b/internal/route/lfs/route_test.go index 1cd93672a..5abb09ddc 100644 --- a/internal/route/lfs/route_test.go +++ b/internal/route/lfs/route_test.go @@ -192,7 +192,6 @@ func TestAuthorize(t *testing.T) { name string accessMode database.AccessMode mockUsersStore func() database.UsersStore - mockReposStore func() database.ReposStore mockStore func() *MockStore expStatusCode int expBody string @@ -217,10 +216,10 @@ func TestAuthorize(t *testing.T) { }) return mock }, - mockReposStore: func() database.ReposStore { - mock := NewMockReposStore() - mock.GetByNameFunc.SetDefaultReturn(nil, database.ErrRepoNotExist{}) - return mock + mockStore: func() *MockStore { + mockStore := NewMockStore() + mockStore.GetRepositoryByNameFunc.SetDefaultReturn(nil, database.ErrRepoNotExist{}) + return mockStore }, expStatusCode: http.StatusNotFound, }, @@ -234,18 +233,14 @@ func TestAuthorize(t *testing.T) { }) return mock }, - mockReposStore: func() database.ReposStore { - mock := NewMockReposStore() - mock.GetByNameFunc.SetDefaultHook(func(ctx context.Context, ownerID int64, name string) (*database.Repository, error) { - return &database.Repository{Name: name}, nil - }) - return mock - }, mockStore: func() *MockStore { mockStore := NewMockStore() mockStore.AuthorizeRepositoryAccessFunc.SetDefaultHook(func(_ context.Context, _ int64, _ int64, desired database.AccessMode, _ database.AccessModeOptions) bool { return desired <= database.AccessModeRead }) + mockStore.GetRepositoryByNameFunc.SetDefaultHook(func(ctx context.Context, ownerID int64, name string) (*database.Repository, error) { + return &database.Repository{Name: name}, nil + }) return mockStore }, expStatusCode: http.StatusNotFound, @@ -261,18 +256,14 @@ func TestAuthorize(t *testing.T) { }) return mock }, - mockReposStore: func() database.ReposStore { - mock := NewMockReposStore() - mock.GetByNameFunc.SetDefaultHook(func(ctx context.Context, ownerID int64, name string) (*database.Repository, error) { - return &database.Repository{Name: name}, nil - }) - return mock - }, mockStore: func() *MockStore { mockStore := NewMockStore() mockStore.AuthorizeRepositoryAccessFunc.SetDefaultHook(func(_ context.Context, _ int64, _ int64, desired database.AccessMode, _ database.AccessModeOptions) bool { return desired <= database.AccessModeRead }) + mockStore.GetRepositoryByNameFunc.SetDefaultHook(func(ctx context.Context, ownerID int64, name string) (*database.Repository, error) { + return &database.Repository{Name: name}, nil + }) return mockStore }, expStatusCode: http.StatusOK, @@ -284,9 +275,6 @@ func TestAuthorize(t *testing.T) { if test.mockUsersStore != nil { database.SetMockUsersStore(t, test.mockUsersStore()) } - if test.mockReposStore != nil { - database.SetMockReposStore(t, test.mockReposStore()) - } mockStore := NewMockStore() if test.mockStore != nil { mockStore = test.mockStore() diff --git a/internal/route/lfs/store.go b/internal/route/lfs/store.go index e7e498d39..c6731f67f 100644 --- a/internal/route/lfs/store.go +++ b/internal/route/lfs/store.go @@ -30,6 +30,10 @@ type Store interface { // AuthorizeRepositoryAccess returns true if the user has as good as desired // access mode to the repository. AuthorizeRepositoryAccess(ctx context.Context, userID, repoID int64, desired database.AccessMode, opts database.AccessModeOptions) bool + + // GetRepositoryByName returns the repository with given owner and name. It + // returns database.ErrRepoNotExist when not found. + GetRepositoryByName(ctx context.Context, ownerID int64, name string) (*database.Repository, error) } type store struct{} @@ -62,3 +66,7 @@ func (*store) GetLFSObjectsByOIDs(ctx context.Context, repoID int64, oids ...lfs func (*store) AuthorizeRepositoryAccess(ctx context.Context, userID, repoID int64, desired database.AccessMode, opts database.AccessModeOptions) bool { return database.Handle.Permissions().Authorize(ctx, userID, repoID, desired, opts) } + +func (*store) GetRepositoryByName(ctx context.Context, ownerID int64, name string) (*database.Repository, error) { + return database.Handle.Repositories().GetByName(ctx, ownerID, name) +} diff --git a/internal/route/repo/http.go b/internal/route/repo/http.go index 291479612..557461743 100644 --- a/internal/route/repo/http.go +++ b/internal/route/repo/http.go @@ -77,7 +77,7 @@ func HTTPContexter(store Store) macaron.Handler { return } - repo, err := database.Repos.GetByName(c.Req.Context(), owner.ID, repoName) + repo, err := store.GetRepositoryByName(c.Req.Context(), owner.ID, repoName) if err != nil { if database.IsErrRepoNotExist(err) { c.Status(http.StatusNotFound) diff --git a/internal/route/repo/issue.go b/internal/route/repo/issue.go index 8696d522c..f96ca40ff 100644 --- a/internal/route/repo/issue.go +++ b/internal/route/repo/issue.go @@ -68,7 +68,7 @@ func MustAllowPulls(c *context.Context) { } // User can send pull request if owns a forked repository. - if c.IsLogged && database.Repos.HasForkedBy(c.Req.Context(), c.Repo.Repository.ID, c.User.ID) { + if c.IsLogged && database.Handle.Repositories().HasForkedBy(c.Req.Context(), c.Repo.Repository.ID, c.User.ID) { c.Repo.PullRequest.Allowed = true c.Repo.PullRequest.HeadInfo = c.User.Name + ":" + c.Repo.BranchName } diff --git a/internal/route/repo/store.go b/internal/route/repo/store.go index e93a14ba0..14a638fed 100644 --- a/internal/route/repo/store.go +++ b/internal/route/repo/store.go @@ -16,6 +16,10 @@ type Store interface { // TouchAccessTokenByID updates the updated time of the given access token to // the current time. TouchAccessTokenByID(ctx context.Context, id int64) error + + // GetRepositoryByName returns the repository with given owner and name. It + // returns database.ErrRepoNotExist when not found. + GetRepositoryByName(ctx context.Context, ownerID int64, name string) (*database.Repository, error) } type store struct{} @@ -32,3 +36,7 @@ func (*store) GetAccessTokenBySHA1(ctx context.Context, sha1 string) (*database. func (*store) TouchAccessTokenByID(ctx context.Context, id int64) error { return database.Handle.AccessTokens().Touch(ctx, id) } + +func (*store) GetRepositoryByName(ctx context.Context, ownerID int64, name string) (*database.Repository, error) { + return database.Handle.Repositories().GetByName(ctx, ownerID, name) +} diff --git a/internal/route/repo/tasks.go b/internal/route/repo/tasks.go index e4a066145..c5d8187a3 100644 --- a/internal/route/repo/tasks.go +++ b/internal/route/repo/tasks.go @@ -44,7 +44,7 @@ func TriggerTask(c *macaron.Context) { return } - repo, err := database.Repos.GetByName(c.Req.Context(), owner.ID, reponame) + repo, err := database.Handle.Repositories().GetByName(c.Req.Context(), owner.ID, reponame) if err != nil { if database.IsErrRepoNotExist(err) { c.Error(http.StatusBadRequest, "Repository does not exist") diff --git a/internal/route/user/home.go b/internal/route/user/home.go index 5fc0cdb23..f227abb5b 100644 --- a/internal/route/user/home.go +++ b/internal/route/user/home.go @@ -125,7 +125,7 @@ func Dashboard(c *context.Context) { // Only user can have collaborative repositories. if !ctxUser.IsOrganization() { - collaborateRepos, err := database.Repos.GetByCollaboratorID(c.Req.Context(), c.User.ID, conf.UI.User.RepoPagingNum, "updated_unix DESC") + collaborateRepos, err := database.Handle.Repositories().GetByCollaboratorID(c.Req.Context(), c.User.ID, conf.UI.User.RepoPagingNum, "updated_unix DESC") if err != nil { c.Error(err, "get accessible repositories by collaborator") return diff --git a/mockgen.yaml b/mockgen.yaml index f74d2ea48..62a38fcf4 100644 --- a/mockgen.yaml +++ b/mockgen.yaml @@ -38,7 +38,6 @@ mocks: interfaces: - UsersStore - TwoFactorsStore - - ReposStore - path: gogs.io/gogs/internal/route/lfs interfaces: - Store