mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-20 16:58:31 +02:00
Fix test
This commit is contained in:
parent
a125a58e81
commit
87ed579357
@ -427,6 +427,7 @@ func GetTreeInformation(ctx context.Context, repo *repo_model.Repository, treePa
|
|||||||
if lastDirEntry.IsRegular() {
|
if lastDirEntry.IsRegular() {
|
||||||
// path.Dir cannot correctly handle .xxx file
|
// path.Dir cannot correctly handle .xxx file
|
||||||
dir, _ = path.Split(treePath)
|
dir, _ = path.Split(treePath)
|
||||||
|
dir = strings.TrimRight(dir, "/")
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
lastDirEntry = rootEntry
|
lastDirEntry = rootEntry
|
||||||
} else {
|
} else {
|
||||||
|
@ -139,14 +139,15 @@ func Test_GetTreeInformation(t *testing.T) {
|
|||||||
treeList, err = GetTreeInformation(ctx2, ctx2.Repo.Repository, "", refName)
|
treeList, err = GetTreeInformation(ctx2, ctx2.Repo.Repository, "", refName)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, treeList, 2)
|
assert.Len(t, treeList, 2)
|
||||||
assert.EqualValues(t, "README.md", treeList[0].Name)
|
|
||||||
assert.EqualValues(t, "README.md", treeList[0].Path)
|
assert.EqualValues(t, "doc", treeList[0].Name)
|
||||||
assert.True(t, treeList[0].IsFile)
|
assert.EqualValues(t, "doc", treeList[0].Path)
|
||||||
|
assert.False(t, treeList[0].IsFile)
|
||||||
assert.Empty(t, treeList[0].Children)
|
assert.Empty(t, treeList[0].Children)
|
||||||
|
|
||||||
assert.EqualValues(t, "doc", treeList[1].Name)
|
assert.EqualValues(t, "README.md", treeList[1].Name)
|
||||||
assert.EqualValues(t, "doc", treeList[1].Path)
|
assert.EqualValues(t, "README.md", treeList[1].Path)
|
||||||
assert.False(t, treeList[1].IsFile)
|
assert.True(t, treeList[1].IsFile)
|
||||||
assert.Empty(t, treeList[1].Children)
|
assert.Empty(t, treeList[1].Children)
|
||||||
|
|
||||||
treeList, err = GetTreeInformation(ctx2, ctx2.Repo.Repository, "doc", refName)
|
treeList, err = GetTreeInformation(ctx2, ctx2.Repo.Repository, "doc", refName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user