2020-05-13 10:15:43 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type FileSyncMap map[string]FileSync
|
|
|
|
|
|
|
|
func (m FileSyncMap) Get(name string, accountID uint, remoteName string) FileSync {
|
|
|
|
if result, ok := m[name]; ok {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
return *NewFileSync(accountID, remoteName)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m FileSyncMap) Pointer(name string, accountID uint, remoteName string) *FileSync {
|
|
|
|
if result, ok := m[name]; ok {
|
|
|
|
return &result
|
|
|
|
}
|
|
|
|
|
|
|
|
return NewFileSync(accountID, remoteName)
|
|
|
|
}
|
|
|
|
|
|
|
|
var FileSyncFixtures = FileSyncMap{
|
|
|
|
"FileSync1": {
|
|
|
|
FileID: 1000000,
|
2022-10-15 21:54:11 +02:00
|
|
|
ServiceID: 1000000,
|
2021-07-22 15:05:23 +02:00
|
|
|
RemoteName: "/20200706-092527-Landscape-München-2020.jpg",
|
|
|
|
Status: "uploaded",
|
2020-05-13 10:15:43 +02:00
|
|
|
Error: "",
|
|
|
|
Errors: 0,
|
|
|
|
File: &FileFixturesExampleJPG,
|
2022-10-15 21:54:11 +02:00
|
|
|
Account: &ServiceFixtureWebdavDummy,
|
2020-05-13 10:15:43 +02:00
|
|
|
RemoteDate: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
|
|
RemoteSize: int64(888),
|
|
|
|
CreatedAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
|
|
UpdatedAt: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
|
|
},
|
|
|
|
"FileSync2": {
|
|
|
|
FileID: 1000000,
|
2022-10-15 21:54:11 +02:00
|
|
|
ServiceID: 1000001,
|
2021-07-22 15:05:23 +02:00
|
|
|
RemoteName: "/20200706-092527-Landscape-Hamburg-2020.jpg",
|
|
|
|
Status: "downloaded",
|
2020-05-13 10:15:43 +02:00
|
|
|
Error: "",
|
|
|
|
Errors: 0,
|
|
|
|
File: &FileFixturesExampleJPG,
|
2022-10-15 21:54:11 +02:00
|
|
|
Account: &ServiceFixtureWebdavDummy2,
|
2020-05-13 10:15:43 +02:00
|
|
|
RemoteDate: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
|
2021-07-22 15:05:23 +02:00
|
|
|
RemoteSize: int64(160),
|
2020-05-13 10:15:43 +02:00
|
|
|
CreatedAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
|
|
UpdatedAt: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
|
|
},
|
2020-07-13 16:44:17 +02:00
|
|
|
"FileSync3": {
|
|
|
|
FileID: 1000000,
|
2022-10-15 21:54:11 +02:00
|
|
|
ServiceID: 1000000,
|
2021-07-22 15:05:23 +02:00
|
|
|
RemoteName: "/20200706-092527-People-2020.jpg",
|
2020-07-13 16:44:17 +02:00
|
|
|
Status: "new",
|
|
|
|
Error: "",
|
|
|
|
Errors: 0,
|
|
|
|
File: &FileFixturesExampleJPG,
|
2022-10-15 21:54:11 +02:00
|
|
|
Account: &ServiceFixtureWebdavDummy,
|
2020-07-13 16:44:17 +02:00
|
|
|
RemoteDate: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
|
2021-07-22 15:05:23 +02:00
|
|
|
RemoteSize: int64(860),
|
2020-07-13 16:44:17 +02:00
|
|
|
CreatedAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
|
|
UpdatedAt: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
|
|
},
|
2020-05-13 10:15:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateFileSyncFixtures inserts known entities into the database for testing.
|
|
|
|
func CreateFileSyncFixtures() {
|
|
|
|
for _, entity := range FileSyncFixtures {
|
|
|
|
Db().Create(&entity)
|
|
|
|
}
|
|
|
|
}
|