1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-22 08:42:32 -05:00
forgejo/tests/integration/markup_external_test.go
silverwind 3918db10c8
Run go generate and go vet on all packages (#30529)
Fixes: https://github.com/go-gitea/gitea/issues/30512

I think this does mean those tools would run on a potential `vendor`
directory, but I'm not sure we really support vendoring of dependencies
anymore.

`release` has a `vendor` prerequisite so likely the source tarballs
contain vendor files?

(cherry picked from commit 8e12ef911a1d10dedb03e3127c42ca76f9850aca)

Conflicts:
	- Makefile
	  Manually adjusted the changes.
2024-04-21 16:28:16 +02:00

39 lines
944 B
Go

// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package integration
import (
"bytes"
"io"
"net/http"
"strings"
"testing"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/tests"
"github.com/stretchr/testify/assert"
)
func TestExternalMarkupRenderer(t *testing.T) {
defer tests.PrepareTestEnv(t)()
if !setting.Database.Type.IsSQLite3() {
t.Skip()
return
}
const repoURL = "user30/renderer"
req := NewRequest(t, "GET", repoURL+"/src/branch/master/README.html")
resp := MakeRequest(t, req, http.StatusOK)
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header()["Content-Type"][0])
bs, err := io.ReadAll(resp.Body)
assert.NoError(t, err)
doc := NewHTMLParser(t, bytes.NewBuffer(bs))
div := doc.Find("div.file-view")
data, err := div.Html()
assert.NoError(t, err)
assert.EqualValues(t, "<div>\n\ttest external renderer\n</div>", strings.TrimSpace(data))
}