aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-11-22 13:48:09 +0800
committerGitHub <noreply@github.com>2024-11-22 05:48:09 +0000
commitc4e27cb27b99dd9528c999fdc8b1073f28be6313 (patch)
treebbd065423fa48e09553918d23bdc7c5daef6e8bd /tests
parent81ac8d914cf5fdfaad3c206223ad0ace1e8c1dcd (diff)
downloadgitea-c4e27cb27b99dd9528c999fdc8b1073f28be6313.tar.gz
gitea-c4e27cb27b99dd9528c999fdc8b1073f28be6313.zip
Refactor markup render system (#32589)
This PR mainly moves some code and introduces `RenderContext.WithXxx` functions
Diffstat (limited to 'tests')
-rw-r--r--tests/fuzz/fuzz_test.go17
1 files changed, 6 insertions, 11 deletions
diff --git a/tests/fuzz/fuzz_test.go b/tests/fuzz/fuzz_test.go
index 25a6ed8213..78d3027547 100644
--- a/tests/fuzz/fuzz_test.go
+++ b/tests/fuzz/fuzz_test.go
@@ -14,27 +14,22 @@ import (
"code.gitea.io/gitea/modules/setting"
)
-var renderContext = markup.RenderContext{
- Ctx: context.Background(),
- Links: markup.Links{
- Base: "https://example.com/go-gitea/gitea",
- },
- Metas: map[string]string{
- "user": "go-gitea",
- "repo": "gitea",
- },
+func newFuzzRenderContext() *markup.RenderContext {
+ return markup.NewRenderContext(context.Background()).
+ WithLinks(markup.Links{Base: "https://example.com/go-gitea/gitea"}).
+ WithMetas(map[string]string{"user": "go-gitea", "repo": "gitea"})
}
func FuzzMarkdownRenderRaw(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
setting.AppURL = "http://localhost:3000/"
- markdown.RenderRaw(&renderContext, bytes.NewReader(data), io.Discard)
+ markdown.RenderRaw(newFuzzRenderContext(), bytes.NewReader(data), io.Discard)
})
}
func FuzzMarkupPostProcess(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
setting.AppURL = "http://localhost:3000/"
- markup.PostProcess(&renderContext, bytes.NewReader(data), io.Discard)
+ markup.PostProcess(newFuzzRenderContext(), bytes.NewReader(data), io.Discard)
})
}