0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-06-12 00:43:23 +02:00

fixed issues for testing

This commit is contained in:
truecode112 2023-05-16 12:27:49 +03:00
parent 9e5f2fd4e3
commit 80f8977e59
3 changed files with 23 additions and 2 deletions

View File

@ -138,7 +138,10 @@ func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string
// FileSize calculates the file size and generate user-friendly string.
func FileSize(s int64) string {
return humanize.Bytes(uint64(s))
// sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"}
// return humanize.humanateBytes(uint64(s), 1000, sizes)
// return humanize.Bytes(uint64(s))
return humanize.IBytes(uint64(s))
}
// Get FileSize bytes value from String.

View File

@ -114,6 +114,13 @@ func TestFileSize(t *testing.T) {
assert.Equal(t, "2.0 EiB", FileSize(size))
}
func TestGetFileSize(t *testing.T) {
var size int64 = 512 * 1024 * 1024 * 1024
s, err := GetFileSize("512 GiB")
assert.Equal(t, s, size)
assert.Equal(t, err, nil)
}
func TestEllipsisString(t *testing.T) {
assert.Equal(t, "...", EllipsisString("foobar", 0))
assert.Equal(t, "...", EllipsisString("foobar", 1))

View File

@ -45,7 +45,18 @@ func Repos(ctx *context.Context) {
}
func UpdateRepoPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.UpdateGlobalRepoFrom)
temp := web.GetForm(ctx)
if temp == nil {
ctx.Data["Err_Repo_Size_Limit"] = ""
explore.RenderRepoSearch(ctx, &explore.RepoSearchOptions{
Private: true,
PageSize: setting.UI.Admin.RepoPagingNum,
TplName: tplRepos,
OnlyShowRelevant: false,
})
return
}
form := temp.(*forms.UpdateGlobalRepoFrom)
ctx.Data["Title"] = ctx.Tr("admin.repositories")
ctx.Data["PageIsAdminRepositories"] = true