mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-23 05:00:02 +02:00
Add package registry quota limits (#21584)
Related #20471 This PR adds global quota limits for the package registry. Settings for individual users/orgs can be added in a seperate PR using the settings table. Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
cb83288530
commit
20674dd05d
20 changed files with 378 additions and 61 deletions
31
modules/setting/packages_test.go
Normal file
31
modules/setting/packages_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package setting
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
ini "gopkg.in/ini.v1"
|
||||
)
|
||||
|
||||
func TestMustBytes(t *testing.T) {
|
||||
test := func(value string) int64 {
|
||||
sec, _ := ini.Empty().NewSection("test")
|
||||
sec.NewKey("VALUE", value)
|
||||
|
||||
return mustBytes(sec, "VALUE")
|
||||
}
|
||||
|
||||
assert.EqualValues(t, -1, test(""))
|
||||
assert.EqualValues(t, -1, test("-1"))
|
||||
assert.EqualValues(t, 0, test("0"))
|
||||
assert.EqualValues(t, 1, test("1"))
|
||||
assert.EqualValues(t, 10000, test("10000"))
|
||||
assert.EqualValues(t, 1000000, test("1 mb"))
|
||||
assert.EqualValues(t, 1048576, test("1mib"))
|
||||
assert.EqualValues(t, 1782579, test("1.7mib"))
|
||||
assert.EqualValues(t, -1, test("1 yib")) // too large
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue