清理代码 & 支持 ignore

This commit is contained in:
dragon
2025-05-09 14:50:10 +08:00
parent 9413188aa9
commit ef31433d91
14 changed files with 405 additions and 118 deletions

View File

@@ -0,0 +1,26 @@
package tests
import (
"testing"
"github.com/stretchr/testify/assert"
"gopkg.d7z.net/gitea-pages/tests/core"
)
func Test_get_render(t *testing.T) {
server := core.NewDefaultTestServer()
defer server.Close()
server.AddFile("org1/repo1/gh-pages/index.html", "hello world")
server.AddFile("org1/repo1/gh-pages/tmpl/index.html", "hello world,{{ .Request.Host }}")
server.AddFile("org1/repo1/gh-pages/.pages.yaml", `
templates:
gotemplate: tmpl/*.html
`)
data, _, err := server.OpenFile("https://org1.example.com/repo1/")
assert.NoError(t, err)
assert.Equal(t, "hello world", string(data))
data, _, err = server.OpenFile("https://org1.example.com/repo1/tmpl/index.html")
assert.NoError(t, err)
assert.Equal(t, "hello world,org1.example.com", string(data))
}