forked from stashapp/stash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// +build linux | ||
|
||
package utils | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// Due to the way some functions work some tests need to be run | ||
// with data for the running OS | ||
|
||
// linux path tests for IsPathInDir (path separator is evaluated at runtime) | ||
var linuxTestPaths = []struct { | ||
basePath string | ||
path string | ||
isInDir bool | ||
}{ | ||
{"/media/.previews", "/media", false}, //1 | ||
{"/media", "/media/.previews", true}, | ||
{"/", "/my/media/path", true}, | ||
{"/opt/stash/media", "/opt/media", false}, | ||
{"/opt/", "/opt/stash/media", true}, | ||
{"/opt/stash/", "/opt/stash", true}, // 6 | ||
} | ||
|
||
func TestIsPathInDirLinux(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
for i, tp := range linuxTestPaths { | ||
assert.Equal(tp.isInDir, IsPathInDir(tp.basePath, tp.path), "Test "+strconv.Itoa(i+1)+":"+tp.basePath+"... failed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// +build windows | ||
|
||
package utils | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// Due to the way some functions work some tests need to be run | ||
// with data for the running OS | ||
|
||
// windows path tests for IsPathInDir (path separator is evaluated at runtime) | ||
var windowsTestPaths = []struct { | ||
basePath string | ||
path string | ||
isInDir bool | ||
}{ | ||
{"c:\\media\\.previews", "c:\\media", false}, //1 | ||
{"c:\\media", "c:\\media\\.previews", true}, | ||
{"c:\\", "c:\\my\\media\\path", true}, | ||
{"\\\\netshare\\stash\\media", "\\\\netshare\\opt\\media", false}, | ||
{"\\\\netshare", "\\\\netshare\\stash\\media", true}, | ||
{"c:\\user\\data\\2", "c:\\user\\data\\2", true}, // 6 | ||
} | ||
|
||
func TestIsPathInDirWindows(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
for i, tp := range windowsTestPaths { | ||
assert.Equal(tp.isInDir, IsPathInDir(tp.basePath, tp.path), "Test "+strconv.Itoa(i+1)+":"+tp.basePath+"... failed") | ||
} | ||
} |