1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Fix test fixtures for user2/lfs.git (#32477)

This commit is contained in:
wxiaoguang
2024-11-12 13:41:22 +08:00
committed by GitHub
parent 4c924bf43c
commit 160ccb5ee2
7 changed files with 14 additions and 25 deletions

View File

@@ -10,6 +10,8 @@ import (
"strings"
"testing"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -94,13 +96,18 @@ func TestLFSRender(t *testing.T) {
t.Run("Invalid", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/invalid")
// the LFS exists
req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/CONTRIBUTING.md")
resp := session.MakeRequest(t, req, http.StatusOK)
content := NewHTMLParser(t, resp.Body).Find("div.file-view").Text()
assert.Contains(t, content, "Testing documents in LFS")
doc := NewHTMLParser(t, resp.Body).doc
content := doc.Find("div.file-view").Text()
assert.Contains(t, content, "oid sha256:9d178b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351")
// then make it disappear
assert.NoError(t, db.TruncateBeans(db.DefaultContext, &git.LFSMetaObject{}))
req = NewRequest(t, "GET", "/user2/lfs/src/branch/master/CONTRIBUTING.md")
resp = session.MakeRequest(t, req, http.StatusOK)
content = NewHTMLParser(t, resp.Body).Find("div.file-view").Text()
assert.Contains(t, content, "oid sha256:7b6b2c88dba9f760a1a58469b67fee2b698ef7e9399c4ca4f34a14ccbe39f623")
})
}