forked from TrueCloudLab/frostfs-node
[#1764] neofs-node: Validate config before usage
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
6f45cc81fc
commit
0fb5c51ac9
7 changed files with 153 additions and 15 deletions
38
cmd/neofs-node/validate_test.go
Normal file
38
cmd/neofs-node/validate_test.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||
configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestValidate(t *testing.T) {
|
||||
const exampleConfigPrefix = "../../config/"
|
||||
t.Run("examples", func(t *testing.T) {
|
||||
p := filepath.Join(exampleConfigPrefix, "example/node")
|
||||
configtest.ForEachFileType(p, func(c *config.Config) {
|
||||
var err error
|
||||
require.NotPanics(t, func() {
|
||||
err = validateConfig(c)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("mainnet", func(t *testing.T) {
|
||||
os.Clearenv() // ENVs have priority over config files, so we do this in tests
|
||||
p := filepath.Join(exampleConfigPrefix, "mainnet/config.yml")
|
||||
c := config.New(config.Prm{}, config.WithConfigFile(p))
|
||||
require.NoError(t, validateConfig(c))
|
||||
})
|
||||
t.Run("testnet", func(t *testing.T) {
|
||||
os.Clearenv() // ENVs have priority over config files, so we do this in tests
|
||||
p := filepath.Join(exampleConfigPrefix, "testnet/config.yml")
|
||||
c := config.New(config.Prm{}, config.WithConfigFile(p))
|
||||
require.NoError(t, validateConfig(c))
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue