mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-03 07:51:55 +00:00
fix: [quota.default].TOTAL
config setting supports unit suffixes (#9252)
Bring the code in line with the documentation that claims the `[quota.default].TOTAL` option supports unit suffixes. Resolves forgejo/forgejo#8996 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9252 Reviewed-by: Lucas <sclu1034@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Brook <brook@noreply.codeberg.org> Co-committed-by: Brook <brook@noreply.codeberg.org>
This commit is contained in:
parent
fd849bb9f2
commit
60cab1bafd
6 changed files with 99 additions and 38 deletions
|
@ -10,27 +10,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMustBytes(t *testing.T) {
|
||||
test := func(value string) int64 {
|
||||
cfg, err := NewConfigProviderFromData("[test]")
|
||||
require.NoError(t, err)
|
||||
sec := cfg.Section("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
|
||||
}
|
||||
|
||||
func Test_getStorageInheritNameSectionTypeForPackages(t *testing.T) {
|
||||
// packages storage inherits from storage if nothing configured
|
||||
iniStr := `
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue