2021-06-02 12:20:05 +00:00
|
|
|
package apiclientconfig_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
|
|
|
apiclientconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/apiclient"
|
|
|
|
configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestApiclientSection(t *testing.T) {
|
|
|
|
t.Run("defaults", func(t *testing.T) {
|
|
|
|
empty := configtest.EmptyConfig()
|
|
|
|
|
|
|
|
require.Equal(t, apiclientconfig.DialTimeoutDefault, apiclientconfig.DialTimeout(empty))
|
2022-09-06 15:23:59 +00:00
|
|
|
require.Equal(t, apiclientconfig.StreamTimeoutDefault, apiclientconfig.StreamTimeout(empty))
|
2022-09-26 12:34:01 +00:00
|
|
|
require.False(t, apiclientconfig.AllowExternal(empty))
|
2021-06-02 12:20:05 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const path = "../../../../config/example/node"
|
|
|
|
|
|
|
|
var fileConfigTest = func(c *config.Config) {
|
|
|
|
require.Equal(t, 15*time.Second, apiclientconfig.DialTimeout(c))
|
2022-09-06 15:23:59 +00:00
|
|
|
require.Equal(t, 20*time.Second, apiclientconfig.StreamTimeout(c))
|
2022-09-26 12:34:01 +00:00
|
|
|
require.True(t, apiclientconfig.AllowExternal(c))
|
2021-06-02 12:20:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
configtest.ForEachFileType(path, fileConfigTest)
|
|
|
|
|
|
|
|
t.Run("ENV", func(t *testing.T) {
|
|
|
|
configtest.ForEnvFileType(path, fileConfigTest)
|
|
|
|
})
|
|
|
|
}
|