snapshot of https://github.com/go-gitea/gitea.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
This commit is contained in:
83
routers/web/repo/treelist_test.go
Normal file
83
routers/web/repo/treelist_test.go
Normal file
@@ -0,0 +1,83 @@
|
||||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"testing"
|
||||
|
||||
pull_model "gitea.dev/models/pull"
|
||||
"gitea.dev/modules/fileicon"
|
||||
"gitea.dev/modules/git"
|
||||
"gitea.dev/services/gitdiff"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestTransformDiffTreeForWeb(t *testing.T) {
|
||||
renderedIconPool := fileicon.NewRenderedIconPool()
|
||||
ret := transformDiffTreeForWeb(renderedIconPool, &gitdiff.DiffTree{Files: []*gitdiff.DiffTreeRecord{
|
||||
{
|
||||
Status: "changed",
|
||||
HeadPath: "dir-a/dir-a-x/file-deep",
|
||||
HeadMode: git.EntryModeBlob,
|
||||
},
|
||||
{
|
||||
Status: "added",
|
||||
HeadPath: "file1",
|
||||
HeadMode: git.EntryModeBlob,
|
||||
},
|
||||
{
|
||||
Status: "renamed",
|
||||
BasePath: "file2-old",
|
||||
HeadPath: "file2",
|
||||
HeadMode: git.EntryModeBlob,
|
||||
},
|
||||
}}, map[string]pull_model.ViewedState{
|
||||
"dir-a/dir-a-x/file-deep": pull_model.Viewed,
|
||||
})
|
||||
|
||||
mockIconForFile := func(id string) template.HTML {
|
||||
return template.HTML(`<svg class="svg git-entry-icon octicon-file" width="16" height="16" aria-hidden="true"><use href="#` + id + `"></use></svg>`)
|
||||
}
|
||||
assert.Equal(t, WebDiffFileTree{
|
||||
TreeRoot: WebDiffFileItem{
|
||||
Children: []*WebDiffFileItem{
|
||||
{
|
||||
EntryMode: "tree",
|
||||
DisplayName: "dir-a/dir-a-x",
|
||||
FullName: "dir-a/dir-a-x",
|
||||
Children: []*WebDiffFileItem{
|
||||
{
|
||||
EntryMode: "",
|
||||
DisplayName: "file-deep",
|
||||
FullName: "dir-a/dir-a-x/file-deep",
|
||||
NameHash: "4acf7eef1c943a09e9f754e93ff190db8583236b",
|
||||
DiffStatus: "changed",
|
||||
IsViewed: true,
|
||||
FileIcon: mockIconForFile(`svg-mfi-file`),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
EntryMode: "",
|
||||
DisplayName: "file1",
|
||||
FullName: "file1",
|
||||
NameHash: "60b27f004e454aca81b0480209cce5081ec52390",
|
||||
DiffStatus: "added",
|
||||
FileIcon: mockIconForFile(`svg-mfi-file`),
|
||||
},
|
||||
{
|
||||
EntryMode: "",
|
||||
DisplayName: "file2",
|
||||
FullName: "file2",
|
||||
OldFullName: "file2-old",
|
||||
NameHash: "cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523",
|
||||
DiffStatus: "renamed",
|
||||
FileIcon: mockIconForFile(`svg-mfi-file`),
|
||||
},
|
||||
},
|
||||
},
|
||||
}, ret)
|
||||
}
|
||||
Reference in New Issue
Block a user