Backend: Improve Dsc regular expression and add test
This commit is contained in:
parent
b1eac027f3
commit
832715f861
3 changed files with 18 additions and 1 deletions
|
@ -61,3 +61,17 @@ func TestConfig_TestdataPath(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(t, "/go/src/github.com/photoprism/photoprism/storage/testdata/testdata", c.TestdataPath())
|
assert.Equal(t, "/go/src/github.com/photoprism/photoprism/storage/testdata/testdata", c.TestdataPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConfig_CreateDirectories(t *testing.T) {
|
||||||
|
c := NewTestConfig()
|
||||||
|
err := c.CreateDirectories()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfig_ConfigFile2(t *testing.T) {
|
||||||
|
c := NewTestConfig()
|
||||||
|
assert.Equal(t, "/go/src/github.com/photoprism/photoprism/storage/testdata/testdata", c.ConfigFile())
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/photoprism/photoprism/pkg/rnd"
|
"github.com/photoprism/photoprism/pkg/rnd"
|
||||||
)
|
)
|
||||||
|
|
||||||
var DscNameRegexp = regexp.MustCompile("\\D{3}[\\d_]\\d{4,8}_?\\d{0,6}(.JPG)?")
|
var DscNameRegexp = regexp.MustCompile("\\D{3}[\\d_]\\d{4,8}_?\\d{0,6}_?\\d{0,6}(.JPG)?")
|
||||||
var UniqueNameRegexp = regexp.MustCompile("[a-f0-9]{8,16}_[a-f0-9]{6,16}_[A-Za-z0-9]{1,20}_?[A-Za-z0-9]{0,4}") // Example: 8263987746_d0a6055c58_o
|
var UniqueNameRegexp = regexp.MustCompile("[a-f0-9]{8,16}_[a-f0-9]{6,16}_[A-Za-z0-9]{1,20}_?[A-Za-z0-9]{0,4}") // Example: 8263987746_d0a6055c58_o
|
||||||
var UUIDNameRegexp = regexp.MustCompile("[A-Fa-f0-9\\-]{16,36}_?[A-Za-z0-9_]{0,20}") // Example: 8263987746_d0a6055c58_o
|
var UUIDNameRegexp = regexp.MustCompile("[A-Fa-f0-9\\-]{16,36}_?[A-Za-z0-9_]{0,20}") // Example: 8263987746_d0a6055c58_o
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,9 @@ func TestIsDscName(t *testing.T) {
|
||||||
assert.False(t, IsDscName("550e8400-e29b-11d4-a716-446655440000"))
|
assert.False(t, IsDscName("550e8400-e29b-11d4-a716-446655440000"))
|
||||||
assert.True(t, IsDscName("IMG_0599.JPG"))
|
assert.True(t, IsDscName("IMG_0599.JPG"))
|
||||||
assert.True(t, IsDscName("IMG_20190721_095643.JPG"))
|
assert.True(t, IsDscName("IMG_20190721_095643.JPG"))
|
||||||
|
assert.True(t, IsDscName("IMG_20190119_135810_145"))
|
||||||
|
//TODO
|
||||||
|
//assert.True(t, IsDscName("IMG_1059_2048px"))
|
||||||
assert.True(t, IsDscName("IMG_20190721_095643"))
|
assert.True(t, IsDscName("IMG_20190721_095643"))
|
||||||
assert.True(t, IsDscName("DSC_20190721_095643"))
|
assert.True(t, IsDscName("DSC_20190721_095643"))
|
||||||
assert.True(t, IsDscName("DSC10599"))
|
assert.True(t, IsDscName("DSC10599"))
|
||||||
|
|
Loading…
Reference in a new issue