2020-09-25 14:28:09 +05:30
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2020-09-25 14:28:09 +05:30
|
|
|
|
|
|
|
package setting
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2023-02-19 21:42:01 +05:30
|
|
|
func Test_getCronSettings(t *testing.T) {
|
2020-09-25 14:28:09 +05:30
|
|
|
type BaseStruct struct {
|
|
|
|
Base bool
|
|
|
|
Second string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Extended struct {
|
|
|
|
BaseStruct
|
|
|
|
Extend bool
|
|
|
|
}
|
|
|
|
|
|
|
|
iniStr := `
|
|
|
|
[cron.test]
|
2023-04-25 20:36:39 +05:30
|
|
|
BASE = true
|
|
|
|
SECOND = white rabbit
|
|
|
|
EXTEND = true
|
2020-09-25 14:28:09 +05:30
|
|
|
`
|
2023-04-25 20:36:39 +05:30
|
|
|
cfg, err := newConfigProviderFromData(iniStr)
|
2023-02-19 21:42:01 +05:30
|
|
|
assert.NoError(t, err)
|
2020-09-25 14:28:09 +05:30
|
|
|
|
|
|
|
extended := &Extended{
|
|
|
|
BaseStruct: BaseStruct{
|
|
|
|
Second: "queen of hearts",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-02-19 21:42:01 +05:30
|
|
|
_, err = getCronSettings(cfg, "test", extended)
|
2020-09-25 14:28:09 +05:30
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.True(t, extended.Base)
|
|
|
|
assert.EqualValues(t, extended.Second, "white rabbit")
|
|
|
|
assert.True(t, extended.Extend)
|
|
|
|
}
|