2020-09-25 16:58:09 +08:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-28 02:20:29 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-09-25 16:58:09 +08:00
|
|
|
|
|
|
|
package setting
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
ini "gopkg.in/ini.v1"
|
|
|
|
)
|
|
|
|
|
2023-02-20 00:12:01 +08:00
|
|
|
func Test_getCronSettings(t *testing.T) {
|
2020-09-25 16:58:09 +08:00
|
|
|
type BaseStruct struct {
|
|
|
|
Base bool
|
|
|
|
Second string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Extended struct {
|
|
|
|
BaseStruct
|
|
|
|
Extend bool
|
|
|
|
}
|
|
|
|
|
|
|
|
iniStr := `
|
|
|
|
[cron.test]
|
|
|
|
Base = true
|
|
|
|
Second = white rabbit
|
|
|
|
Extend = true
|
|
|
|
`
|
2023-02-20 00:12:01 +08:00
|
|
|
cfg, err := ini.Load([]byte(iniStr))
|
|
|
|
assert.NoError(t, err)
|
2020-09-25 16:58:09 +08:00
|
|
|
|
|
|
|
extended := &Extended{
|
|
|
|
BaseStruct: BaseStruct{
|
|
|
|
Second: "queen of hearts",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-02-20 00:12:01 +08:00
|
|
|
_, err = getCronSettings(cfg, "test", extended)
|
2020-09-25 16:58:09 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.True(t, extended.Base)
|
|
|
|
assert.EqualValues(t, extended.Second, "white rabbit")
|
|
|
|
assert.True(t, extended.Extend)
|
|
|
|
}
|