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": {
ID: "85d1ea7d382c",
PlaceID: PlaceFixtures.Get("mexico").ID,
2020-05-08 11:46:09 +02:00
LocName: "Adosada Platform",
LocCategory: "botanical garden",
Place: PlaceFixtures.Pointer("mexico"),
2020-05-08 11:46:09 +02:00
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"caravan park": {
ID: "1ef75a71a36c",
PlaceID: "1ef75a71a36c",
Place: &Place{
ID: "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": {
ID: "1ef744d1e28c",
PlaceID: PlaceFixtures.Get("zinkwazi").ID,
Place: PlaceFixtures.Pointer("zinkwazi"),
2020-05-08 11:46:09 +02:00
LocName: "Zinkwazi Beach",
LocCategory: "beach",
2020-05-08 11:46:09 +02:00
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
2020-05-11 17:01:05 +02:00
"hassloch": {
ID: "1ef744d1e280",
PlaceID: PlaceFixtures.Get("holidaypark").ID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("holidaypark"),
LocName: "Holiday Park",
LocCategory: "park",
2020-05-11 17:01:05 +02:00
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"emptyNameLongCity": {
ID: "1ef744d1e281",
PlaceID: PlaceFixtures.Get("emptyNameLongCity").ID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("emptyNameLongCity"),
LocName: "",
LocCategory: "botanical garden",
2020-05-11 17:01:05 +02:00
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"emptyNameShortCity": {
ID: "1ef744d1e282",
PlaceID: PlaceFixtures.Get("emptyNameShortCity").ID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("emptyNameShortCity"),
LocName: "",
LocCategory: "botanical garden",
2020-05-11 17:01:05 +02:00
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"veryLongLocName": {
ID: "1ef744d1e283",
PlaceID: PlaceFixtures.Get("veryLongLocName").ID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("veryLongLocName"),
LocName: "longlonglonglonglonglonglonglonglonglonglonglonglongName",
LocCategory: "cape",
2020-05-11 17:01:05 +02:00
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"mediumLongLocName": {
ID: "1ef744d1e283",
PlaceID: PlaceFixtures.Get("mediumLongLocName").ID,
2020-05-11 17:01:05 +02:00
Place: PlaceFixtures.Pointer("mediumLongLocName"),
LocName: "longlonglonglonglonglongName",
LocCategory: "botanical garden",
2020-05-11 17:01:05 +02:00
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)
}
}