zrepl/internal/config/config_include_test.go
Zeyad Tamimi c92c141b51 Added include configuration support
A relatively straight forward change that adds "include" key support in
the main configuration file.

The config parser uses the list under this key to open the included
configuration files parse them as configs and append their jobs to the
main config file.
2025-02-22 11:58:21 -08:00

44 lines
872 B
Go

package config
import (
"testing"
"github.com/kr/pretty"
"github.com/stretchr/testify/require"
)
func TestIncludeSingle(t *testing.T) {
path := "./samples/include.yml"
t.Run(path, func(t *testing.T) {
config, err := ParseConfig(path)
if err != nil {
t.Errorf("error parsing %s:\n%+v", path, err)
}
require.NotNil(t, config)
require.NotNil(t, config.Global)
require.NotEmpty(t, config.Jobs)
t.Logf("file: %s", path)
t.Log(pretty.Sprint(config))
})
}
func TestIncludeDirectory(t *testing.T) {
path := "./samples/include_directory.yml"
t.Run(path, func(t *testing.T) {
config, err := ParseConfig(path)
if err != nil {
t.Errorf("error parsing %s:\n%+v", path, err)
}
require.NotNil(t, config)
require.NotNil(t, config.Global)
require.NotEmpty(t, config.Jobs)
t.Logf("file: %s", path)
t.Log(pretty.Sprint(config))
})
}