aboutsummaryrefslogtreecommitdiffstats
path: root/models/renderhelper/repo_comment_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/renderhelper/repo_comment_test.go')
-rw-r--r--models/renderhelper/repo_comment_test.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/models/renderhelper/repo_comment_test.go b/models/renderhelper/repo_comment_test.go
index 01e20b9e02..3b13bff73c 100644
--- a/models/renderhelper/repo_comment_test.go
+++ b/models/renderhelper/repo_comment_test.go
@@ -4,7 +4,6 @@
package renderhelper
import (
- "context"
"testing"
repo_model "code.gitea.io/gitea/models/repo"
@@ -21,7 +20,7 @@ func TestRepoComment(t *testing.T) {
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
t.Run("AutoLink", func(t *testing.T) {
- rctx := NewRenderContextRepoComment(context.Background(), repo1).WithMarkupType(markdown.MarkupName)
+ rctx := NewRenderContextRepoComment(t.Context(), repo1).WithMarkupType(markdown.MarkupName)
rendered, err := markup.RenderString(rctx, `
65f1bf27bc3bf70f64657658635e66094edbcb4d
#1
@@ -36,7 +35,7 @@ func TestRepoComment(t *testing.T) {
})
t.Run("AbsoluteAndRelative", func(t *testing.T) {
- rctx := NewRenderContextRepoComment(context.Background(), repo1).WithMarkupType(markdown.MarkupName)
+ rctx := NewRenderContextRepoComment(t.Context(), repo1).WithMarkupType(markdown.MarkupName)
// It is Gitea's old behavior, the relative path is resolved to the repo path
// It is different from GitHub, GitHub resolves relative links to current page's path
@@ -56,7 +55,7 @@ func TestRepoComment(t *testing.T) {
})
t.Run("WithCurrentRefPath", func(t *testing.T) {
- rctx := NewRenderContextRepoComment(context.Background(), repo1, RepoCommentOptions{CurrentRefPath: "/commit/1234"}).
+ rctx := NewRenderContextRepoComment(t.Context(), repo1, RepoCommentOptions{CurrentRefPath: "/commit/1234"}).
WithMarkupType(markdown.MarkupName)
// the ref path is only used to render commit message: a commit message is rendered at the commit page with its commit ID path
@@ -73,4 +72,11 @@ func TestRepoComment(t *testing.T) {
<a href="/user2/repo1/commit/1234/image" target="_blank" rel="nofollow noopener"><img src="/user2/repo1/commit/1234/image" alt="./image"/></a></p>
`, rendered)
})
+
+ t.Run("NoRepo", func(t *testing.T) {
+ rctx := NewRenderContextRepoComment(t.Context(), nil).WithMarkupType(markdown.MarkupName)
+ rendered, err := markup.RenderString(rctx, "any")
+ assert.NoError(t, err)
+ assert.Equal(t, "<p>any</p>\n", rendered)
+ })
}