You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cron_test.go 816B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package setting
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. ini "gopkg.in/ini.v1"
  9. )
  10. func Test_GetCronSettings(t *testing.T) {
  11. type BaseStruct struct {
  12. Base bool
  13. Second string
  14. }
  15. type Extended struct {
  16. BaseStruct
  17. Extend bool
  18. }
  19. iniStr := `
  20. [cron.test]
  21. Base = true
  22. Second = white rabbit
  23. Extend = true
  24. `
  25. Cfg, _ = ini.Load([]byte(iniStr))
  26. extended := &Extended{
  27. BaseStruct: BaseStruct{
  28. Second: "queen of hearts",
  29. },
  30. }
  31. _, err := GetCronSettings("test", extended)
  32. assert.NoError(t, err)
  33. assert.True(t, extended.Base)
  34. assert.EqualValues(t, extended.Second, "white rabbit")
  35. assert.True(t, extended.Extend)
  36. }