diff options
author | Daniel Baumann <daniel@debian.org> | 2025-01-24 08:57:48 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2025-01-24 08:57:48 +0100 |
commit | c70c95ecbea0487586212a9437d120989a6c6e31 (patch) | |
tree | 140d166690b4cf72737075f15001eee07bfb4d6c /internal/pkg/config/config_test.go | |
parent | Initial commit. (diff) | |
download | forgejo-runner-debian.tar.xz forgejo-runner-debian.zip |
Adding upstream version 6.2.0.HEADupstream/6.2.0upstreamdebian
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'internal/pkg/config/config_test.go')
-rw-r--r-- | internal/pkg/config/config_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/pkg/config/config_test.go b/internal/pkg/config/config_test.go new file mode 100644 index 0000000..43d0f10 --- /dev/null +++ b/internal/pkg/config/config_test.go @@ -0,0 +1,46 @@ +// 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) + }) +} + +func TestDefaultSettings(t *testing.T) { + config, err := LoadDefault("") + assert.NoError(t, err) + + assert.EqualValues(t, config.Container.DockerHost, "-") + assert.EqualValues(t, config.Log.JobLevel, "info") + assert.EqualValues(t, config.Container.ForceRebuild, false) +} |