aboutsummaryrefslogtreecommitdiff
path: root/modules/markup/html_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/markup/html_test.go')
-rw-r--r--modules/markup/html_test.go35
1 files changed, 22 insertions, 13 deletions
diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go
index f6aabc627..a7cf81250 100644
--- a/modules/markup/html_test.go
+++ b/modules/markup/html_test.go
@@ -5,12 +5,14 @@
package markup_test
import (
+ "context"
"io"
"strings"
"testing"
"code.gitea.io/gitea/modules/emoji"
"code.gitea.io/gitea/modules/git"
+ "code.gitea.io/gitea/modules/log"
. "code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
@@ -25,14 +27,21 @@ var localMetas = map[string]string{
"repoPath": "../../integrations/gitea-repositories-meta/user13/repo11.git/",
}
+func TestMain(m *testing.M) {
+ setting.LoadAllowEmpty()
+ if err := git.InitSimple(context.Background()); err != nil {
+ log.Fatal("git init failed, err: %v", err)
+ }
+}
+
func TestRender_Commits(t *testing.T) {
setting.AppURL = TestAppURL
test := func(input, expected string) {
buffer, err := RenderString(&RenderContext{
- Ctx: git.DefaultContext,
- Filename: ".md",
- URLPrefix: TestRepoURL,
- Metas: localMetas,
+ Ctx: git.DefaultContext,
+ RelativePath: ".md",
+ URLPrefix: TestRepoURL,
+ Metas: localMetas,
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
@@ -80,9 +89,9 @@ func TestRender_CrossReferences(t *testing.T) {
test := func(input, expected string) {
buffer, err := RenderString(&RenderContext{
- Filename: "a.md",
- URLPrefix: setting.AppSubURL,
- Metas: localMetas,
+ RelativePath: "a.md",
+ URLPrefix: setting.AppSubURL,
+ Metas: localMetas,
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
@@ -124,8 +133,8 @@ func TestRender_links(t *testing.T) {
test := func(input, expected string) {
buffer, err := RenderString(&RenderContext{
- Filename: "a.md",
- URLPrefix: TestRepoURL,
+ RelativePath: "a.md",
+ URLPrefix: TestRepoURL,
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
@@ -223,8 +232,8 @@ func TestRender_email(t *testing.T) {
test := func(input, expected string) {
res, err := RenderString(&RenderContext{
- Filename: "a.md",
- URLPrefix: TestRepoURL,
+ RelativePath: "a.md",
+ URLPrefix: TestRepoURL,
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(res))
@@ -281,8 +290,8 @@ func TestRender_emoji(t *testing.T) {
test := func(input, expected string) {
expected = strings.ReplaceAll(expected, "&", "&")
buffer, err := RenderString(&RenderContext{
- Filename: "a.md",
- URLPrefix: TestRepoURL,
+ RelativePath: "a.md",
+ URLPrefix: TestRepoURL,
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))