2020-06-29 11:10:24 +02:00
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2020-07-06 11:31:03 +02:00
|
|
|
func TestIsAsciiID(t *testing.T) {
|
|
|
|
assert.False(t, IsAsciiID("lt9k3pw1wowuy3c2"))
|
|
|
|
assert.False(t, IsAsciiID("dafbfeb8-a129-4e7c-9cf0-e7996a701cdb"))
|
|
|
|
assert.False(t, IsAsciiID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
|
2020-07-14 15:00:14 +02:00
|
|
|
assert.True(t, IsAsciiID("55785BAC-9A4B-4747-B090-EE123FFEE437"))
|
2020-07-06 11:31:03 +02:00
|
|
|
assert.False(t, IsAsciiID("550e8400-e29b-11d4-a716-446655440000"))
|
|
|
|
assert.False(t, IsAsciiID("IMG_0599.JPG"))
|
|
|
|
assert.True(t, IsAsciiID("DSC10599"))
|
|
|
|
assert.True(t, IsAsciiID("IQVG4929"))
|
2020-07-14 15:00:14 +02:00
|
|
|
assert.True(t, IsAsciiID("DSC_0599"))
|
2020-07-06 11:31:03 +02:00
|
|
|
assert.False(t, IsAsciiID("iqVG4929"))
|
2020-07-14 15:00:14 +02:00
|
|
|
assert.True(t, IsAsciiID("20091117_203458_ERROR000"))
|
|
|
|
assert.True(t, IsAsciiID("20091117_203458_12345678"))
|
2020-07-06 11:31:03 +02:00
|
|
|
assert.True(t, IsAsciiID("4B1FEF2D1CF4A5BE38B263E0637EDEAD"))
|
|
|
|
assert.True(t, IsAsciiID("123"))
|
2020-07-14 15:00:14 +02:00
|
|
|
assert.True(t, IsAsciiID("_"))
|
2020-07-06 11:31:03 +02:00
|
|
|
assert.False(t, IsAsciiID(""))
|
|
|
|
assert.False(t, IsAsciiID("20191117-153400-Central-Park-New-York-2019-3qy.mov"))
|
|
|
|
assert.False(t, IsAsciiID("e98eb86480a72bd585d228a709f0622f90e86cbc.jpg"))
|
|
|
|
assert.False(t, IsAsciiID("IMG_8115.jpg"))
|
|
|
|
assert.False(t, IsAsciiID("01 Introduction Businessmodel.pdf"))
|
|
|
|
assert.False(t, IsAsciiID("A regular file name with 121345678643 numbers"))
|
2020-07-14 15:00:14 +02:00
|
|
|
assert.True(t, IsGenerated("2013-06-06_DMC-LX5_P1080235"))
|
2020-06-29 11:10:24 +02:00
|
|
|
}
|
2020-07-07 15:13:42 +02:00
|
|
|
|
|
|
|
func TestIsInt(t *testing.T) {
|
|
|
|
assert.True(t, IsInt("123"))
|
|
|
|
assert.False(t, IsInt(""))
|
|
|
|
}
|
2020-07-11 16:46:29 +02:00
|
|
|
|
|
|
|
func TestIsUniqueName(t *testing.T) {
|
|
|
|
assert.False(t, IsUniqueName("lt9k3pw1wowuy3c2"))
|
|
|
|
assert.True(t, IsUniqueName("dafbfeb8-a129-4e7c-9cf0-e7996a701cdb"))
|
|
|
|
assert.True(t, IsUniqueName("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
|
|
|
|
assert.True(t, IsUniqueName("55785BAC-9A4B-4747-B090-EE123FFEE437"))
|
|
|
|
assert.True(t, IsUniqueName("550e8400-e29b-11d4-a716-446655440000"))
|
|
|
|
assert.False(t, IsUniqueName("IMG_0599.JPG"))
|
|
|
|
assert.False(t, IsUniqueName("DSC10599"))
|
|
|
|
assert.False(t, IsUniqueName("IQVG4929"))
|
|
|
|
assert.True(t, IsUniqueName("7045C6DD-448A-405D-B2A4-6F4DA0D44F2F"))
|
|
|
|
assert.False(t, IsUniqueName("7045C6DD-448A-405D-B2A4-6F4DA0D44F2F-FOO"))
|
|
|
|
assert.True(t, IsUniqueName("7045C6DD-448A-405D-B2A4-6F4DA0D44F2F_L0_001"))
|
|
|
|
assert.True(t, IsUniqueName("10298590_856989717698278_4041733760069394245_o"))
|
|
|
|
assert.True(t, IsUniqueName("49007520716_67ff0ce0ec_4k"))
|
|
|
|
assert.True(t, IsUniqueName("8263987746_d0a6055c58_o"))
|
|
|
|
assert.True(t, IsUniqueName("20091117_203458_ERROR000"))
|
|
|
|
assert.True(t, IsUniqueName("20091117_203458_12345678"))
|
|
|
|
assert.True(t, IsUniqueName("4B1FEF2D1CF4A5BE38B263E0637EDEAD"))
|
|
|
|
assert.False(t, IsUniqueName("123"))
|
|
|
|
assert.False(t, IsUniqueName("_"))
|
|
|
|
assert.False(t, IsUniqueName(""))
|
|
|
|
assert.False(t, IsUniqueName("20191117-153400-Central-Park-New-York-2019-3qy.mov"))
|
|
|
|
assert.False(t, IsUniqueName("e98eb86480a72bd585d228a709f0622f90e86cbc.jpg"))
|
|
|
|
assert.False(t, IsUniqueName("IMG_8115.jpg"))
|
|
|
|
assert.False(t, IsUniqueName("01 Introduction Businessmodel.pdf"))
|
|
|
|
assert.False(t, IsUniqueName("A regular file name with 121345678643 numbers"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIsDscName(t *testing.T) {
|
|
|
|
assert.False(t, IsDscName("lt9k3pw1wowuy3c2"))
|
|
|
|
assert.False(t, IsDscName("dafbfeb8-a129-4e7c-9cf0-e7996a701cdb"))
|
|
|
|
assert.False(t, IsDscName("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
|
|
|
|
assert.False(t, IsDscName("55785BAC-9A4B-4747-B090-EE123FFEE437"))
|
|
|
|
assert.False(t, IsDscName("550e8400-e29b-11d4-a716-446655440000"))
|
|
|
|
assert.True(t, IsDscName("IMG_0599.JPG"))
|
2020-07-14 15:00:14 +02:00
|
|
|
assert.True(t, IsDscName("IMG_0599.jpg"))
|
|
|
|
assert.True(t, IsDscName("IMG_0599.Jpg"))
|
|
|
|
assert.True(t, IsDscName("IMG_0599_100px"))
|
|
|
|
assert.True(t, IsDscName("IMG_8115.jpg"))
|
2020-07-11 16:46:29 +02:00
|
|
|
assert.True(t, IsDscName("IMG_20190721_095643.JPG"))
|
2020-07-14 08:46:20 +02:00
|
|
|
assert.True(t, IsDscName("IMG_20190119_135810_145"))
|
2020-07-14 15:00:14 +02:00
|
|
|
assert.True(t, IsDscName("IMG_1059_2048px"))
|
2020-07-11 16:46:29 +02:00
|
|
|
assert.True(t, IsDscName("IMG_20190721_095643"))
|
|
|
|
assert.True(t, IsDscName("DSC_20190721_095643"))
|
|
|
|
assert.True(t, IsDscName("DSC10599"))
|
2020-07-14 15:00:14 +02:00
|
|
|
assert.True(t, IsDscName("DSC10599_3500px"))
|
2020-07-11 16:46:29 +02:00
|
|
|
assert.False(t, IsDscName("IQVG4929"))
|
|
|
|
assert.False(t, IsDscName("49007520716_67ff0ce0ec_4k"))
|
|
|
|
assert.False(t, IsDscName("8263987746_d0a6055c58_o"))
|
|
|
|
assert.False(t, IsDscName("20091117_203458_ERROR000"))
|
|
|
|
assert.False(t, IsDscName("20091117_203458_12345678"))
|
|
|
|
assert.False(t, IsDscName("4B1FEF2D1CF4A5BE38B263E0637EDEAD"))
|
|
|
|
assert.False(t, IsDscName("123"))
|
|
|
|
assert.False(t, IsDscName("_"))
|
|
|
|
assert.False(t, IsDscName(""))
|
|
|
|
assert.False(t, IsDscName("20191117-153400-Central-Park-New-York-2019-3qy.mov"))
|
|
|
|
assert.False(t, IsDscName("e98eb86480a72bd585d228a709f0622f90e86cbc.jpg"))
|
|
|
|
assert.False(t, IsDscName("01 Introduction Businessmodel.pdf"))
|
|
|
|
assert.False(t, IsDscName("A regular file name with 121345678643 numbers"))
|
|
|
|
}
|
2020-07-14 15:00:14 +02:00
|
|
|
|
|
|
|
func TestIsGenerated(t *testing.T) {
|
|
|
|
assert.True(t, IsGenerated("lt9k3pw1wowuy3c2"))
|
|
|
|
assert.True(t, IsGenerated("dafbfeb8-a129-4e7c-9cf0-e7996a701cdb"))
|
|
|
|
assert.True(t, IsGenerated("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
|
|
|
|
assert.True(t, IsGenerated("55785BAC-9A4B-4747-B090-EE123FFEE437"))
|
|
|
|
assert.True(t, IsGenerated("550e8400-e29b-11d4-a716-446655440000"))
|
|
|
|
assert.True(t, IsGenerated("IMG_0599.JPG"))
|
|
|
|
assert.True(t, IsGenerated("DSC10599"))
|
|
|
|
assert.True(t, IsGenerated("IQVG4929"))
|
|
|
|
assert.True(t, IsGenerated("49007520716_67ff0ce0ec_4k"))
|
|
|
|
assert.True(t, IsGenerated("8263987746_d0a6055c58_o"))
|
|
|
|
assert.True(t, IsGenerated("20091117_203458_ERROR000"))
|
|
|
|
assert.True(t, IsGenerated("20091117_203458_12345678"))
|
|
|
|
assert.True(t, IsGenerated("4B1FEF2D1CF4A5BE38B263E0637EDEAD"))
|
|
|
|
assert.True(t, IsGenerated("123"))
|
|
|
|
assert.True(t, IsGenerated("_"))
|
|
|
|
assert.False(t, IsGenerated(""))
|
|
|
|
assert.False(t, IsGenerated("20191117-153400-Central-Park-New-York-2019-3qy.mov"))
|
|
|
|
assert.True(t, IsGenerated("e98eb86480a72bd585d228a709f0622f90e86cbc.jpg"))
|
|
|
|
assert.True(t, IsGenerated("IMG_8115.jpg"))
|
|
|
|
assert.False(t, IsGenerated("01 Introduction Businessmodel.pdf"))
|
|
|
|
assert.False(t, IsGenerated("A regular file name with 121345678643 numbers"))
|
|
|
|
assert.True(t, IsGenerated("2013-06-06_DMC-LX5_P1080235.JPG"))
|
|
|
|
assert.False(t, IsGenerated("The quick brown fox jumps over the lazy dog"))
|
|
|
|
assert.False(t, IsGenerated("QUICK BROWN FOX"))
|
2020-08-14 15:36:48 +02:00
|
|
|
assert.True(t, IsGenerated("_MG_9831-112.jpg"))
|
2023-06-27 19:20:11 +02:00
|
|
|
assert.True(t, IsGenerated("IMG_1234_78_78.jpg"))
|
|
|
|
assert.True(t, IsGenerated("20091117_203458_12345678.jpg"))
|
|
|
|
|
2020-07-14 15:00:14 +02:00
|
|
|
}
|