92e6c4fe1e
Extends DownloadSettings with 4 additional options: - Name: File name pattern for downloaded files (existed) - Disabled: Disables downloads - Originals: Only download files stored in "originals" folder - MediaRaw: Include RAW image files - MediaSidecar: Include metadata sidecar files (JSON, XMP, YAML)
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package entity
|
|
|
|
import (
|
|
"math/rand"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/photoprism/photoprism/pkg/rnd"
|
|
)
|
|
|
|
func TestSave(t *testing.T) {
|
|
var r = rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
|
|
t.Run("HasCreatedUpdatedAt", func(t *testing.T) {
|
|
id := 99999 + r.Intn(10000)
|
|
m := Photo{ID: uint(id), PhotoUID: rnd.GenerateUID('p'), UpdatedAt: TimeStamp(), CreatedAt: TimeStamp()}
|
|
|
|
if err := m.Save(); err != nil {
|
|
t.Fatal(err)
|
|
return
|
|
}
|
|
|
|
if err := m.Find(); err != nil {
|
|
t.Fatal(err)
|
|
return
|
|
}
|
|
})
|
|
t.Run("HasCreatedAt", func(t *testing.T) {
|
|
id := 99999 + r.Intn(10000)
|
|
m := Photo{ID: uint(id), PhotoUID: rnd.GenerateUID('p'), CreatedAt: TimeStamp()}
|
|
|
|
if err := m.Save(); err != nil {
|
|
t.Fatal(err)
|
|
return
|
|
}
|
|
|
|
if err := m.Find(); err != nil {
|
|
t.Fatal(err)
|
|
return
|
|
}
|
|
})
|
|
t.Run("NoCreatedAt", func(t *testing.T) {
|
|
id := 99999 + r.Intn(10000)
|
|
m := Photo{ID: uint(id), PhotoUID: rnd.GenerateUID('p'), CreatedAt: TimeStamp()}
|
|
|
|
if err := m.Save(); err != nil {
|
|
t.Fatal(err)
|
|
return
|
|
}
|
|
|
|
if err := m.Find(); err != nil {
|
|
t.Fatal(err)
|
|
return
|
|
}
|
|
})
|
|
}
|