mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Prefer studio name later in filename (#2057)
This commit is contained in:
76
pkg/match/path_test.go
Normal file
76
pkg/match/path_test.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package match
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_nameMatchesPath(t *testing.T) {
|
||||
const name = "first last"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
want int
|
||||
}{
|
||||
{
|
||||
"exact",
|
||||
name,
|
||||
0,
|
||||
},
|
||||
{
|
||||
"partial",
|
||||
"first",
|
||||
-1,
|
||||
},
|
||||
{
|
||||
"separator",
|
||||
"first.last",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"separator",
|
||||
"first-last",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"separator",
|
||||
"first_last",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"separators",
|
||||
"first.-_ last",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"within string",
|
||||
"before_first last/after",
|
||||
6,
|
||||
},
|
||||
{
|
||||
"not within string",
|
||||
"beforefirst last/after",
|
||||
-1,
|
||||
},
|
||||
{
|
||||
"not within string",
|
||||
"before/first lastafter",
|
||||
-1,
|
||||
},
|
||||
{
|
||||
"not within string",
|
||||
"first last1",
|
||||
-1,
|
||||
},
|
||||
{
|
||||
"not within string",
|
||||
"1first last",
|
||||
-1,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := nameMatchesPath(name, tt.path); got != tt.want {
|
||||
t.Errorf("nameMatchesPath() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user