Skip to content

Commit 678ab3f

Browse files
committed
address comments, add tests
1 parent 0a2101d commit 678ab3f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pkg/config/load_error_paths_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ func TestLoadConfigFile_ConfigFileNotFoundError(t *testing.T) {
222222

223223
// TestReadConfigFileContent_ReadError tests error path at load.go:308-312.
224224
func TestReadConfigFileContent_ReadError(t *testing.T) {
225-
// Try to read a nonexistent file
226-
_, err := readConfigFileContent("/nonexistent/path/atmos.yaml")
225+
// Try to read a nonexistent file.
226+
_, err := readConfigFileContent(filepath.Join(string(os.PathSeparator), "nonexistent", "path", "atmos.yaml"))
227227
assert.Error(t, err)
228228
assert.ErrorIs(t, err, errUtils.ErrReadConfig)
229229
}
@@ -441,8 +441,8 @@ func TestMergeConfigFile_ReadFileError(t *testing.T) {
441441
v := viper.New()
442442
v.SetConfigType("yaml")
443443

444-
// Try to read non-existent file
445-
err := mergeConfigFile("/nonexistent/path/config.yaml", v)
444+
// Try to read non-existent file.
445+
err := mergeConfigFile(filepath.Join(string(os.PathSeparator), "nonexistent", "path", "config.yaml"), v)
446446
assert.Error(t, err)
447447
}
448448

toolchain/installer/extract.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ func (i *Installer) extractFilesFromDir(tempDir, binaryPath string, tool *regist
245245
// Try with .exe extension (common for Windows binaries in archives).
246246
srcWithExe := src + windowsExeExt
247247
if _, exeErr := os.Stat(srcWithExe); exeErr != nil {
248+
if !os.IsNotExist(exeErr) {
249+
return fmt.Errorf("%w: failed to stat file in archive: %s: %w", ErrFileOperation, srcWithExe, exeErr)
250+
}
248251
return fmt.Errorf("%w: file not found in archive: %s", ErrToolNotFound, expandedSrcPath)
249252
}
250253
src = srcWithExe

0 commit comments

Comments
 (0)