diff options
Diffstat (limited to 'routers/api/v1/misc/markup_test.go')
-rw-r--r-- | routers/api/v1/misc/markup_test.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/routers/api/v1/misc/markup_test.go b/routers/api/v1/misc/markup_test.go index abffdf3516..6b8c09034a 100644 --- a/routers/api/v1/misc/markup_test.go +++ b/routers/api/v1/misc/markup_test.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/contexttest" @@ -24,6 +25,7 @@ const AppURL = "http://localhost:3000/" func testRenderMarkup(t *testing.T, mode string, wiki bool, filePath, text, expectedBody string, expectedCode int) { setting.AppURL = AppURL + defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableInternalAttributes, true)() context := "/gogits/gogs" if !wiki { context += path.Join("/src/branch/main", path.Dir(filePath)) @@ -38,13 +40,13 @@ func testRenderMarkup(t *testing.T, mode string, wiki bool, filePath, text, expe ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markup") web.SetForm(ctx, &options) Markup(ctx) - actual := strings.ReplaceAll(resp.Body.String(), ` data-markdown-generated-content=""`, "") - assert.Equal(t, expectedBody, actual) + assert.Equal(t, expectedBody, resp.Body.String()) assert.Equal(t, expectedCode, resp.Code) resp.Body.Reset() } func testRenderMarkdown(t *testing.T, mode string, wiki bool, text, responseBody string, responseCode int) { + defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableInternalAttributes, true)() setting.AppURL = AppURL context := "/gogits/gogs" if !wiki { @@ -59,8 +61,7 @@ func testRenderMarkdown(t *testing.T, mode string, wiki bool, text, responseBody ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown") web.SetForm(ctx, &options) Markdown(ctx) - actual := strings.ReplaceAll(resp.Body.String(), ` data-markdown-generated-content=""`, "") - assert.Equal(t, responseBody, actual) + assert.Equal(t, responseBody, resp.Body.String()) assert.Equal(t, responseCode, resp.Code) resp.Body.Reset() } @@ -158,8 +159,8 @@ Here are some links to the most important topics. You can find the full list of <a href="http://localhost:3000/gogits/gogs/media/branch/main/path/image.png" target="_blank" rel="nofollow noopener"><img src="http://localhost:3000/gogits/gogs/media/branch/main/path/image.png" alt="Image"/></a></p> `, http.StatusOK) - testRenderMarkup(t, "file", true, "path/test.unknown", "## Test", "Unsupported render extension: .unknown\n", http.StatusUnprocessableEntity) - testRenderMarkup(t, "unknown", true, "", "## Test", "Unknown mode: unknown\n", http.StatusUnprocessableEntity) + testRenderMarkup(t, "file", false, "path/test.unknown", "## Test", "unsupported file to render: \"path/test.unknown\"\n", http.StatusUnprocessableEntity) + testRenderMarkup(t, "unknown", false, "", "## Test", "Unknown mode: unknown\n", http.StatusUnprocessableEntity) } var simpleCases = []string{ |