Skip to content

Commit 160ccb5

Browse files
authored
Fix test fixtures for user2/lfs.git (#32477)
1 parent 4c924bf commit 160ccb5

File tree

7 files changed

+14
-25
lines changed

7 files changed

+14
-25
lines changed

models/fixtures/lfs_meta_object.yml

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
# These are the LFS objects in user2/lfs.git
2-
# user2/lfs is an INVALID repository
3-
#
4-
# commit e9c32647bab825977942598c0efa415de300304b (HEAD -> master)
5-
# Author: Rowan Bohde <[email protected]>
6-
# Date: Thu Aug 1 14:38:23 2024 -0500
7-
#
8-
# add invalid lfs file
92
-
103

114
id: 1
@@ -18,7 +11,7 @@
1811

1912
id: 2
2013
oid: 2eccdb43825d2a49d99d542daa20075cff1d97d9d2349a8977efe9c03661737c
21-
size: 107 # real size is 2048
14+
size: 2048
2215
repository_id: 54
2316
created_unix: 1671607299
2417

@@ -37,12 +30,3 @@
3730
size: 25
3831
repository_id: 54
3932
created_unix: 1671607299
40-
41-
# this file is missing
42-
# -
43-
#
44-
# id: 5
45-
# oid: 9d178b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351
46-
# size: 25
47-
# repository_id: 54
48-
# created_unix: 1671607299

tests/gitea-repositories-meta/user2/lfs.git/objects/30/77e1c4c8964613df72c37d14275c1eda5228a9

-2
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e9c32647bab825977942598c0efa415de300304b
1+
73cf03db6ece34e12bf91e8853dc58f678f2f82d

tests/integration/lfs_view_test.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"strings"
1111
"testing"
1212

13+
"code.gitea.io/gitea/models/db"
14+
"code.gitea.io/gitea/models/git"
1315
repo_model "code.gitea.io/gitea/models/repo"
1416
"code.gitea.io/gitea/models/unittest"
1517
user_model "code.gitea.io/gitea/models/user"
@@ -94,13 +96,18 @@ func TestLFSRender(t *testing.T) {
9496
t.Run("Invalid", func(t *testing.T) {
9597
defer tests.PrintCurrentTest(t)()
9698

97-
req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/invalid")
99+
// the LFS exists
100+
req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/CONTRIBUTING.md")
98101
resp := session.MakeRequest(t, req, http.StatusOK)
102+
content := NewHTMLParser(t, resp.Body).Find("div.file-view").Text()
103+
assert.Contains(t, content, "Testing documents in LFS")
99104

100-
doc := NewHTMLParser(t, resp.Body).doc
101-
102-
content := doc.Find("div.file-view").Text()
103-
assert.Contains(t, content, "oid sha256:9d178b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351")
105+
// then make it disappear
106+
assert.NoError(t, db.TruncateBeans(db.DefaultContext, &git.LFSMetaObject{}))
107+
req = NewRequest(t, "GET", "/user2/lfs/src/branch/master/CONTRIBUTING.md")
108+
resp = session.MakeRequest(t, req, http.StatusOK)
109+
content = NewHTMLParser(t, resp.Body).Find("div.file-view").Text()
110+
assert.Contains(t, content, "oid sha256:7b6b2c88dba9f760a1a58469b67fee2b698ef7e9399c4ca4f34a14ccbe39f623")
104111
})
105112
}
106113

0 commit comments

Comments
 (0)