summaryrefslogtreecommitdiffstats
path: root/models/wiki_test.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2018-05-02 21:56:19 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2018-05-02 21:56:19 +0800
commitc58e1e437bafe2023b34c16d03f22764ece94d38 (patch)
tree2d3b5450ce14e5c93be722e356c2efc90dd244b9 /models/wiki_test.go
parent0ca359cdb41175a5527daaaf0e3bfb7f4861c87b (diff)
downloadgitea-c58e1e437bafe2023b34c16d03f22764ece94d38.tar.gz
gitea-c58e1e437bafe2023b34c16d03f22764ece94d38.zip
test: reduce testing time. (#3885)
Diffstat (limited to 'models/wiki_test.go')
-rw-r--r--models/wiki_test.go36
1 files changed, 22 insertions, 14 deletions
diff --git a/models/wiki_test.go b/models/wiki_test.go
index a142a58f35..5280b3ea01 100644
--- a/models/wiki_test.go
+++ b/models/wiki_test.go
@@ -153,6 +153,7 @@ func TestRepository_LocalWikiPath(t *testing.T) {
}
func TestRepository_AddWikiPage(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
const wikiContent = "This is the wiki content"
const commitMsg = "Commit message"
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
@@ -161,23 +162,30 @@ func TestRepository_AddWikiPage(t *testing.T) {
"Another page",
"Here's a <tag> and a/slash",
} {
- PrepareTestEnv(t)
- assert.NoError(t, repo.AddWikiPage(doer, wikiName, wikiContent, commitMsg))
- expectedPath := path.Join(repo.LocalWikiPath(), WikiNameToFilename(wikiName))
- assert.True(t, com.IsExist(expectedPath))
+ wikiName := wikiName
+ t.Run("test wiki exist: "+wikiName, func(t *testing.T) {
+ t.Parallel()
+ assert.NoError(t, repo.AddWikiPage(doer, wikiName, wikiContent, commitMsg))
+ expectedPath := path.Join(repo.LocalWikiPath(), WikiNameToFilename(wikiName))
+ assert.True(t, com.IsExist(expectedPath))
+ })
}
- // test for already-existing wiki name
- PrepareTestEnv(t)
- err := repo.AddWikiPage(doer, "Home", wikiContent, commitMsg)
- assert.Error(t, err)
- assert.True(t, IsErrWikiAlreadyExist(err))
+ t.Run("check wiki already exist", func(t *testing.T) {
+ t.Parallel()
+ // test for already-existing wiki name
+ err := repo.AddWikiPage(doer, "Home", wikiContent, commitMsg)
+ assert.Error(t, err)
+ assert.True(t, IsErrWikiAlreadyExist(err))
+ })
- // test for reserved wiki name
- PrepareTestEnv(t)
- err = repo.AddWikiPage(doer, "_edit", wikiContent, commitMsg)
- assert.Error(t, err)
- assert.True(t, IsErrWikiReservedName(err))
+ t.Run("check wiki reserved name", func(t *testing.T) {
+ t.Parallel()
+ // test for reserved wiki name
+ err := repo.AddWikiPage(doer, "_edit", wikiContent, commitMsg)
+ assert.Error(t, err)
+ assert.True(t, IsErrWikiReservedName(err))
+ })
}
func TestRepository_EditWikiPage(t *testing.T) {