photoprism/internal/entity/location_fixtures.go

120 lines
3.1 KiB
Go
Raw Normal View History

2020-05-08 11:46:09 +02:00
package entity
import "time"
type LocationMap map[string]Location
func (m LocationMap) Get(name string) Location {
if result, ok := m[name]; ok {
return result
}
return UnknownLocation
}
func (m LocationMap) Pointer(name string) *Location {
if result, ok := m[name]; ok {
return &result
}
return &UnknownLocation
}
var LocationFixtures = LocationMap{
2020-05-08 11:46:09 +02:00
"mexico": {
LocUID: "85d1ea7d382c",
PlaceUID: PlaceFixtures.Get("mexico").PlaceUID,
2020-05-08 11:46:09 +02:00
LocName: "Adosada Platform",
LocCategory: "tourism",
Place: PlaceFixtures.Pointer("mexico"),
2020-05-08 11:46:09 +02:00
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"caravan park": {
LocUID: "1ef75a71a36c",
PlaceUID: "1ef75a71a36c",
Place: &Place{
PlaceUID: "1ef75a71a36",
LocLabel: "Mandeni, KwaZulu-Natal, South Africa",
LocCity: "Mandeni",
LocState: "KwaZulu-Natal",
LocCountry: "za",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
2020-05-08 11:46:09 +02:00
LocName: "Lobotes Caravan Park",
LocCategory: "camping",
LocSource: "manual",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"zinkwazi": {
LocUID: "1ef744d1e28c",
PlaceUID: PlaceFixtures.Get("zinkwazi").PlaceUID,
Place: PlaceFixtures.Pointer("zinkwazi"),
2020-05-08 11:46:09 +02:00
LocName: "Zinkwazi Beach",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
2020-05-11 17:01:05 +02:00
"hassloch": {
LocUID: "1ef744d1e280",
PlaceUID: PlaceFixtures.Get("holidaypark").PlaceUID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("holidaypark"),
LocName: "Holiday Park",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"emptyNameLongCity": {
LocUID: "1ef744d1e281",
PlaceUID: PlaceFixtures.Get("emptyNameLongCity").PlaceUID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("emptyNameLongCity"),
LocName: "",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"emptyNameShortCity": {
LocUID: "1ef744d1e282",
PlaceUID: PlaceFixtures.Get("emptyNameShortCity").PlaceUID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("emptyNameShortCity"),
LocName: "",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"veryLongLocName": {
LocUID: "1ef744d1e283",
PlaceUID: PlaceFixtures.Get("veryLongLocName").PlaceUID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("veryLongLocName"),
LocName: "longlonglonglonglonglonglonglonglonglonglonglonglongName",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"mediumLongLocName": {
LocUID: "1ef744d1e283",
PlaceUID: PlaceFixtures.Get("mediumLongLocName").PlaceUID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("mediumLongLocName"),
LocName: "longlonglonglonglonglongName",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
2020-05-08 11:46:09 +02:00
}
// CreateLocationFixtures inserts known entities into the database for testing.
func CreateLocationFixtures() {
for _, entity := range LocationFixtures {
Db().Create(&entity)
}
}