github.com/argoproj/argo-cd@v1.8.7/util/app/path/path_test.go (about) 1 package path 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestPathRoot(t *testing.T) { 10 _, err := Path("./testdata", "/") 11 assert.EqualError(t, err, "/: app path is absolute") 12 } 13 14 func TestPathAbsolute(t *testing.T) { 15 _, err := Path("./testdata", "/etc/passwd") 16 assert.EqualError(t, err, "/etc/passwd: app path is absolute") 17 } 18 19 func TestPathDotDot(t *testing.T) { 20 _, err := Path("./testdata", "..") 21 assert.EqualError(t, err, "..: app path outside root") 22 } 23 24 func TestPathDotDotSlash(t *testing.T) { 25 _, err := Path("./testdata", "../") 26 assert.EqualError(t, err, "../: app path outside root") 27 } 28 29 func TestPathDot(t *testing.T) { 30 _, err := Path("./testdata", ".") 31 assert.NoError(t, err) 32 } 33 34 func TestPathDotSlash(t *testing.T) { 35 _, err := Path("./testdata", "./") 36 assert.NoError(t, err) 37 } 38 39 func TestNonExistentPath(t *testing.T) { 40 _, err := Path("./testdata", "does-not-exist") 41 assert.EqualError(t, err, "does-not-exist: app path does not exist") 42 } 43 44 func TestPathNotDir(t *testing.T) { 45 _, err := Path("./testdata", "file.txt") 46 assert.EqualError(t, err, "file.txt: app path is not a directory") 47 }