Skip to content

Commit

Permalink
test: fix TestGetConfigFromContext on Windows
Browse files Browse the repository at this point in the history
Failing test caused by hardcoded relative path check which is different
for Windows.

Close #3305

Signed-off-by: Ekaterina Pavlova <[email protected]>
  • Loading branch information
AliceInHunterland committed Feb 7, 2024
1 parent 51ac153 commit 86219e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cli/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func TestGetConfigFromContext(t *testing.T) {
ctx := cli.NewContext(cli.NewApp(), set, nil)
cfg, err := options.GetConfigFromContext(ctx)
require.NoError(t, err)
require.Equal(t, "../../config/chains/testnet", cfg.ApplicationConfiguration.DBConfiguration.LevelDBOptions.DataDirectoryPath)
baseConfigPath := filepath.FromSlash("../../config")
expectedDBPath := filepath.Join(baseConfigPath, "chains", "testnet")
require.Equal(t, expectedDBPath, cfg.ApplicationConfiguration.DBConfiguration.LevelDBOptions.DataDirectoryPath)
require.Equal(t, "/cn_wallet.json", cfg.ApplicationConfiguration.Consensus.UnlockWallet.Path)
require.Equal(t, "/notary_wallet.json", cfg.ApplicationConfiguration.P2PNotary.UnlockWallet.Path)
})
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func LoadFile(configPath string, relativePath ...string) (Config, error) {
// updateRelativePaths updates relative paths in the config structure based on the provided relative path.
func updateRelativePaths(relativePath string, config *Config) {
updatePath := func(path *string) {
if *path != "" && !filepath.IsAbs(*path) {
unifiedPath := *path
if *path != "" && !filepath.IsAbs(*path) && unifiedPath[0] != '/' {
*path = filepath.Join(relativePath, *path)
}
}
Expand Down

0 comments on commit 86219e9

Please sign in to comment.