mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 15:23:14 -05:00
tests: Let CreateDeclarativeRepoWithOptions create a Wiki too
Add a new member to `DeclarativeRepoOptions`: `WikiBranch`. If specified, create a Wiki with the given branch, and a single "Home" page. This will be used by an upcoming test. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
c647e8639f
commit
6d2f645363
1 changed files with 18 additions and 0 deletions
|
@ -46,6 +46,7 @@ import (
|
||||||
repo_service "code.gitea.io/gitea/services/repository"
|
repo_service "code.gitea.io/gitea/services/repository"
|
||||||
files_service "code.gitea.io/gitea/services/repository/files"
|
files_service "code.gitea.io/gitea/services/repository/files"
|
||||||
user_service "code.gitea.io/gitea/services/user"
|
user_service "code.gitea.io/gitea/services/user"
|
||||||
|
wiki_service "code.gitea.io/gitea/services/wiki"
|
||||||
"code.gitea.io/gitea/tests"
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
@ -658,6 +659,7 @@ type DeclarativeRepoOptions struct {
|
||||||
EnabledUnits optional.Option[[]unit_model.Type]
|
EnabledUnits optional.Option[[]unit_model.Type]
|
||||||
DisabledUnits optional.Option[[]unit_model.Type]
|
DisabledUnits optional.Option[[]unit_model.Type]
|
||||||
Files optional.Option[[]*files_service.ChangeRepoFile]
|
Files optional.Option[[]*files_service.ChangeRepoFile]
|
||||||
|
WikiBranch optional.Option[string]
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateDeclarativeRepoWithOptions(t *testing.T, owner *user_model.User, opts DeclarativeRepoOptions) (*repo_model.Repository, string, func()) {
|
func CreateDeclarativeRepoWithOptions(t *testing.T, owner *user_model.User, opts DeclarativeRepoOptions) (*repo_model.Repository, string, func()) {
|
||||||
|
@ -734,6 +736,22 @@ func CreateDeclarativeRepoWithOptions(t *testing.T, owner *user_model.User, opts
|
||||||
sha = resp.Commit.SHA
|
sha = resp.Commit.SHA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there's a Wiki branch specified, create a wiki, and a default wiki page.
|
||||||
|
if opts.WikiBranch.Has() {
|
||||||
|
// Set the wiki branch in the database first
|
||||||
|
repo.WikiBranch = opts.WikiBranch.Value()
|
||||||
|
err := repo_model.UpdateRepositoryCols(db.DefaultContext, repo, "wiki_branch")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
// Initialize the wiki
|
||||||
|
err = wiki_service.InitWiki(db.DefaultContext, repo)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
// Add a new wiki page
|
||||||
|
err = wiki_service.AddWikiPage(db.DefaultContext, owner, repo, "Home", "Welcome to the wiki!", "Add a Home page")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
// Return the repo, the top commit, and a defer-able function to delete the
|
// Return the repo, the top commit, and a defer-able function to delete the
|
||||||
// repo.
|
// repo.
|
||||||
return repo, sha, func() {
|
return repo, sha, func() {
|
||||||
|
|
Loading…
Reference in a new issue