1// Copyright 2024 The Forgejo Authors. All rights reserved.2// SPDX-License-Identifier: MIT34package config56import (7 "testing"8 "time"910 "github.com/stretchr/testify/assert"11)1213func TestConfigTune(t *testing.T) {14 c := &Config{15 Runner: Runner{},16 }1718 t.Run("Public instance tuning", func(t *testing.T) {19 c.Runner.FetchInterval = 60 * time.Second20 c.Tune("https://codeberg.org")21 assert.EqualValues(t, 60*time.Second, c.Runner.FetchInterval)2223 c.Runner.FetchInterval = 2 * time.Second24 c.Tune("https://codeberg.org")25 assert.EqualValues(t, 30*time.Second, c.Runner.FetchInterval)26 })2728 t.Run("Non-public instance tuning", func(t *testing.T) {29 c.Runner.FetchInterval = 60 * time.Second30 c.Tune("https://example.com")31 assert.EqualValues(t, 60*time.Second, c.Runner.FetchInterval)3233 c.Runner.FetchInterval = 2 * time.Second34 c.Tune("https://codeberg.com")35 assert.EqualValues(t, 2*time.Second, c.Runner.FetchInterval)36 })37}