home: fix tests

This commit is contained in:
Stanislav Chzhen 2025-10-21 10:17:59 +03:00
parent 8e2e1d871f
commit aff0466ba7

View File

@ -11,9 +11,6 @@ import (
)
func TestConfigFilePath(t *testing.T) {
origDir, err := os.Getwd()
require.NoError(t, err)
const (
realConf = "real.yaml"
linkConf = "conf.link"
@ -27,7 +24,7 @@ func TestConfigFilePath(t *testing.T) {
missingPath := filepath.Join(workDir, missingConf)
brokenLinkPath := filepath.Join(workDir, brokenLinkConf)
err = os.Symlink(targetPath, linkPath)
err := os.Symlink(targetPath, linkPath)
require.NoError(t, err)
err = os.Symlink(missingPath, brokenLinkPath)
@ -40,6 +37,14 @@ func TestConfigFilePath(t *testing.T) {
otherDir := t.TempDir()
// Canonicalize the absolute path (e.g., on macOS: /var -> /private/var; on
// Windows: RUNNER~1 -> runneradmin).
wantAbs := targetPath
p, err := filepath.EvalSymlinks(wantAbs)
if err == nil {
wantAbs = p
}
testCases := []struct {
name string
chDir string
@ -49,7 +54,7 @@ func TestConfigFilePath(t *testing.T) {
name: "absolute_path",
chDir: "",
confPath: targetPath,
want: targetPath,
want: wantAbs,
}, {
name: "relative_path",
chDir: "",
@ -75,12 +80,7 @@ func TestConfigFilePath(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if tc.chDir != "" {
err = os.Chdir(tc.chDir)
require.NoError(t, err)
testutil.CleanupAndRequireSuccess(t, func() (err error) {
return os.Chdir(origDir)
})
t.Chdir(tc.chDir)
}
ctx := testutil.ContextWithTimeout(t, testTimeout)