2024-01-05 15:07:15 +00:00
|
|
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConfigTune(t *testing.T) {
|
|
|
|
c := &Config{
|
|
|
|
Runner: Runner{},
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("Public instance tuning", func(t *testing.T) {
|
|
|
|
c.Runner.FetchInterval = 60 * time.Second
|
|
|
|
c.Tune("https://codeberg.org")
|
|
|
|
assert.EqualValues(t, 60*time.Second, c.Runner.FetchInterval)
|
|
|
|
|
|
|
|
c.Runner.FetchInterval = 2 * time.Second
|
|
|
|
c.Tune("https://codeberg.org")
|
|
|
|
assert.EqualValues(t, 30*time.Second, c.Runner.FetchInterval)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Non-public instance tuning", func(t *testing.T) {
|
|
|
|
c.Runner.FetchInterval = 60 * time.Second
|
|
|
|
c.Tune("https://example.com")
|
|
|
|
assert.EqualValues(t, 60*time.Second, c.Runner.FetchInterval)
|
|
|
|
|
|
|
|
c.Runner.FetchInterval = 2 * time.Second
|
|
|
|
c.Tune("https://codeberg.com")
|
|
|
|
assert.EqualValues(t, 2*time.Second, c.Runner.FetchInterval)
|
|
|
|
})
|
|
|
|
}
|
2024-10-30 21:11:19 +00:00
|
|
|
|
|
|
|
func TestDefaultSettings(t *testing.T) {
|
|
|
|
config, err := LoadDefault("")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-11-15 21:33:36 +00:00
|
|
|
assert.EqualValues(t, config.Container.DockerHost, "-")
|
2024-10-30 21:11:19 +00:00
|
|
|
assert.EqualValues(t, config.Log.JobLevel, "info")
|
|
|
|
}
|