32 lines
912 B
Go
32 lines
912 B
Go
|
|
package config
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os"
|
||
|
|
"path/filepath"
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/stretchr/testify/assert"
|
||
|
|
"github.com/stretchr/testify/require"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestReadAndInitConfigReadsNestedDataRTManualSync(t *testing.T) {
|
||
|
|
configPath := filepath.Join(t.TempDir(), "config.yaml")
|
||
|
|
contents := []byte(`
|
||
|
|
dataRT:
|
||
|
|
manual_sync:
|
||
|
|
protocol_cl3611_url: "http://127.0.0.1:9001"
|
||
|
|
protocol_104_url: "http://127.0.0.1:9002"
|
||
|
|
api_path: "/api/manual"
|
||
|
|
timeout: 3s
|
||
|
|
`)
|
||
|
|
require.NoError(t, os.WriteFile(configPath, contents, 0o600))
|
||
|
|
|
||
|
|
cfg := ReadAndInitConfig(filepath.Dir(configPath), "config", "yaml")
|
||
|
|
|
||
|
|
assert.Equal(t, "http://127.0.0.1:9001", cfg.DataRTConfig.ManualSync.ProtocolCL3611URL)
|
||
|
|
assert.Equal(t, "http://127.0.0.1:9002", cfg.DataRTConfig.ManualSync.Protocol104URL)
|
||
|
|
assert.Equal(t, "/api/manual", cfg.DataRTConfig.ManualSync.APIPath)
|
||
|
|
assert.Equal(t, 3*time.Second, cfg.DataRTConfig.ManualSync.Timeout)
|
||
|
|
}
|