photoprism/internal/entity/file_share_fixtures.go

58 lines
1.4 KiB
Go
Raw Normal View History

2020-05-13 10:15:43 +02:00
package entity
import (
"time"
)
type FileShareMap map[string]FileShare
func (m FileShareMap) Get(name string, fileID, accountID uint, remoteName string) FileShare {
if result, ok := m[name]; ok {
return result
}
return *NewFileShare(fileID, accountID, remoteName)
}
func (m FileShareMap) Pointer(name string, fileID, accountID uint, remoteName string) *FileShare {
if result, ok := m[name]; ok {
return &result
}
return NewFileShare(fileID, accountID, remoteName)
}
var FileShareFixtures = FileShareMap{
"FileShare1": {
FileID: 1000000,
AccountID: 1000000,
2021-07-22 15:05:23 +02:00
RemoteName: "/20100729-015747-Urlaub-2010.jpg",
2020-05-14 15:04:53 +02:00
Status: FileShareShared,
2020-05-13 10:15:43 +02:00
Error: "",
Errors: 0,
File: nil,
Account: &AccountFixtureWebdavDummy,
CreatedAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
UpdatedAt: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
},
"FileShare2": {
FileID: 1000000,
AccountID: 1000001,
2021-07-22 15:05:23 +02:00
RemoteName: "/20200729-015747-Dog-2020.jpg",
2020-05-14 15:04:53 +02:00
Status: FileShareNew,
2020-05-13 10:15:43 +02:00
Error: "",
Errors: 0,
File: nil,
Account: &AccountFixtureWebdavDummy2,
CreatedAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
UpdatedAt: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
},
}
// CreateFileShareFixtures inserts known entities into the database for testing.
func CreateFileShareFixtures() {
for _, entity := range FileShareFixtures {
Db().Create(&entity)
}
}