diff options
Diffstat (limited to 'helpers/path_test.go')
-rw-r--r-- | helpers/path_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/helpers/path_test.go b/helpers/path_test.go index a1769f1da..bd8f8ed49 100644 --- a/helpers/path_test.go +++ b/helpers/path_test.go @@ -25,6 +25,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/spf13/afero" "github.com/spf13/viper" ) @@ -141,6 +143,29 @@ func TestGetRelativePath(t *testing.T) { } } +func TestGetRealPath(t *testing.T) { + d1, err := ioutil.TempDir("", "d1") + defer os.Remove(d1) + fs := afero.NewOsFs() + + rp1, err := GetRealPath(fs, d1) + assert.NoError(t, err) + assert.Equal(t, d1, rp1) + + sym := filepath.Join(os.TempDir(), "d1sym") + err = os.Symlink(d1, sym) + defer os.Remove(sym) + assert.NoError(t, err) + + rp2, err := GetRealPath(fs, sym) + assert.NoError(t, err) + + // On OS X, the temp folder is itself a symbolic link (to /private...) + // This has to do for now. + assert.True(t, strings.HasSuffix(rp2, d1)) + +} + func TestMakePathRelative(t *testing.T) { type test struct { inPath, path1, path2, output string |