mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 22:13:26 +09:00
fix(setting): honor bare -1 for timeout settings (#39181)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ package setting
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -136,3 +137,15 @@ func TestDisableSaving(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "k1 = a\nk2 = y\nk3 = z\n", string(bs))
|
||||
}
|
||||
|
||||
func TestConfigValueRead(t *testing.T) {
|
||||
cfg, _ := NewConfigProviderFromData(`
|
||||
neg = -1
|
||||
zero = 0
|
||||
hour = 1h
|
||||
`)
|
||||
assert.Equal(t, -1*time.Second, cfg.Section("").Key("neg").MustDuration(9999))
|
||||
assert.EqualValues(t, 0, cfg.Section("").Key("zero").MustDuration(9999))
|
||||
assert.Equal(t, time.Hour, cfg.Section("").Key("hour").MustDuration(9999))
|
||||
assert.Equal(t, time.Duration(9999), cfg.Section("").Key("def").MustDuration(9999))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user