frostfs-node/cmd/neofs-node/config/test/config.go
Leonard Lyubich b8a5f09174 [#493] node/config: Export useful functions into a separate test package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-01 11:45:38 +03:00

34 lines
688 B
Go

package configtest
import "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
func fromFile(path string) *config.Config {
var p config.Prm
return config.New(p,
config.WithConfigFile(path),
)
}
func forEachFile(paths []string, f func(*config.Config)) {
for i := range paths {
f(fromFile(paths[i]))
}
}
// ForEachFileType passes configs read from next files:
// - `<pref>.yaml`;
// - `<pref>.json`.
func ForEachFileType(pref string, f func(*config.Config)) {
forEachFile([]string{
pref + ".yaml",
pref + ".json",
}, f)
}
// EmptyConfig returns config without any values and sections.
func EmptyConfig() *config.Config {
var p config.Prm
return config.New(p)
}