forked from TrueCloudLab/frostfs-node
[#493] node/config: Export useful functions into a separate test package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
c645781b98
commit
b8a5f09174
4 changed files with 39 additions and 29 deletions
34
cmd/neofs-node/config/test/config.go
Normal file
34
cmd/neofs-node/config/test/config.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue