Backend: Add tests fixtures
This commit is contained in:
parent
bd59dc2564
commit
c0a2da8bab
4 changed files with 68 additions and 21 deletions
|
@ -22,11 +22,11 @@ var FileFixtures = map[string]File{
|
||||||
FileSidecar: false,
|
FileSidecar: false,
|
||||||
FileVideo: false,
|
FileVideo: false,
|
||||||
FileMissing: false,
|
FileMissing: false,
|
||||||
FileDuplicate: false,
|
FileDuplicate: true,
|
||||||
FilePortrait: false,
|
FilePortrait: true,
|
||||||
FileWidth: 3648,
|
FileWidth: 3648,
|
||||||
FileHeight: 2736,
|
FileHeight: 2736,
|
||||||
FileOrientation: 1,
|
FileOrientation: 0,
|
||||||
FileAspectRatio: 1.33333,
|
FileAspectRatio: 1.33333,
|
||||||
FileMainColor: "green",
|
FileMainColor: "green",
|
||||||
FileColors: "929299991",
|
FileColors: "929299991",
|
||||||
|
@ -191,7 +191,7 @@ var FileFixtures = map[string]File{
|
||||||
FileColors: "266111000",
|
FileColors: "266111000",
|
||||||
FileLuminance: "DC42844C8",
|
FileLuminance: "DC42844C8",
|
||||||
FileDiff: 800,
|
FileDiff: 800,
|
||||||
FileChroma: 26,
|
FileChroma: 4,
|
||||||
FileNotes: "",
|
FileNotes: "",
|
||||||
FileError: "",
|
FileError: "",
|
||||||
Share: []FileShare{},
|
Share: []FileShare{},
|
||||||
|
|
|
@ -18,4 +18,5 @@ func CreateTestFixtures() {
|
||||||
CreatePlaceFixtures()
|
CreatePlaceFixtures()
|
||||||
CreateFileShareFixtures()
|
CreateFileShareFixtures()
|
||||||
CreateFileSyncFixtures()
|
CreateFileSyncFixtures()
|
||||||
|
CreateLensFixtures()
|
||||||
}
|
}
|
||||||
|
|
46
internal/entity/lens_fixtures.go
Normal file
46
internal/entity/lens_fixtures.go
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LensMap map[string]Lens
|
||||||
|
|
||||||
|
func (m LensMap) Get(name string) Lens {
|
||||||
|
if result, ok := m[name]; ok {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
return *NewLens(name, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m LensMap) Pointer(name string) *Lens {
|
||||||
|
if result, ok := m[name]; ok {
|
||||||
|
return &result
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewLens(name, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
var LensFixtures = LensMap{
|
||||||
|
"lens-f-380": {
|
||||||
|
ID: 1000000,
|
||||||
|
LensSlug: "lens-f-380",
|
||||||
|
LensModel: "F380",
|
||||||
|
LensMake: "Apple",
|
||||||
|
LensType: "",
|
||||||
|
LensOwner: "Test",
|
||||||
|
LensDescription: "",
|
||||||
|
LensNotes: "Notes",
|
||||||
|
CreatedAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||||
|
UpdatedAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||||
|
DeletedAt: nil,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateLensFixtures inserts known entities into the database for testing.
|
||||||
|
func CreateLensFixtures() {
|
||||||
|
for _, entity := range LensFixtures {
|
||||||
|
Db().Create(&entity)
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ var PhotoFixtures = PhotoMap{
|
||||||
PhotoAltitude: 0,
|
PhotoAltitude: 0,
|
||||||
PhotoIso: 0,
|
PhotoIso: 0,
|
||||||
PhotoFocalLength: 0,
|
PhotoFocalLength: 0,
|
||||||
PhotoFNumber: 0,
|
PhotoFNumber: 5,
|
||||||
PhotoExposure: "",
|
PhotoExposure: "",
|
||||||
CameraID: 0,
|
CameraID: 0,
|
||||||
CameraSerial: "",
|
CameraSerial: "",
|
||||||
|
@ -61,9 +61,9 @@ var PhotoFixtures = PhotoMap{
|
||||||
Description: DescriptionFixtures.Get("lake", 1000000),
|
Description: DescriptionFixtures.Get("lake", 1000000),
|
||||||
DescriptionSrc: "",
|
DescriptionSrc: "",
|
||||||
Camera: CameraFixtures.Pointer("canon-eos-6d"),
|
Camera: CameraFixtures.Pointer("canon-eos-6d"),
|
||||||
Lens: nil,
|
Lens: LensFixtures.Pointer("lens-f-380"),
|
||||||
Location: nil,
|
Location: nil,
|
||||||
Place: nil,
|
Place: PlaceFixtures.Pointer("teotihuacan"),
|
||||||
Links: []Link{},
|
Links: []Link{},
|
||||||
Keywords: []Keyword{},
|
Keywords: []Keyword{},
|
||||||
Albums: []Album{
|
Albums: []Album{
|
||||||
|
@ -115,7 +115,7 @@ var PhotoFixtures = PhotoMap{
|
||||||
Description: Description{},
|
Description: Description{},
|
||||||
DescriptionSrc: "",
|
DescriptionSrc: "",
|
||||||
Camera: CameraFixtures.Pointer("canon-eos-6d"),
|
Camera: CameraFixtures.Pointer("canon-eos-6d"),
|
||||||
Lens: nil,
|
Lens: LensFixtures.Pointer("lens-f-380"),
|
||||||
Location: nil,
|
Location: nil,
|
||||||
Place: nil,
|
Place: nil,
|
||||||
Links: []Link{},
|
Links: []Link{},
|
||||||
|
@ -164,7 +164,7 @@ var PhotoFixtures = PhotoMap{
|
||||||
Description: Description{},
|
Description: Description{},
|
||||||
DescriptionSrc: "",
|
DescriptionSrc: "",
|
||||||
Camera: nil,
|
Camera: nil,
|
||||||
Lens: nil,
|
Lens: LensFixtures.Pointer("lens-f-380"),
|
||||||
Location: nil,
|
Location: nil,
|
||||||
Place: nil,
|
Place: nil,
|
||||||
Links: []Link{},
|
Links: []Link{},
|
||||||
|
@ -264,10 +264,10 @@ var PhotoFixtures = PhotoMap{
|
||||||
PhotoMonth: 7,
|
PhotoMonth: 7,
|
||||||
Description: Description{},
|
Description: Description{},
|
||||||
DescriptionSrc: "",
|
DescriptionSrc: "",
|
||||||
Camera: nil,
|
Camera: CameraFixtures.Pointer("canon-eos-6d"),
|
||||||
Lens: nil,
|
Lens: LensFixtures.Pointer("lens-f-380"),
|
||||||
Location: nil,
|
Location: &LocationFixturesMexico,
|
||||||
Place: nil,
|
Place: PlaceFixtures.Pointer("teotihuacan"),
|
||||||
Links: []Link{},
|
Links: []Link{},
|
||||||
Keywords: []Keyword{
|
Keywords: []Keyword{
|
||||||
KeywordFixtures.Get("bridge"),
|
KeywordFixtures.Get("bridge"),
|
||||||
|
@ -317,10 +317,10 @@ var PhotoFixtures = PhotoMap{
|
||||||
PhotoMonth: 7,
|
PhotoMonth: 7,
|
||||||
Description: Description{},
|
Description: Description{},
|
||||||
DescriptionSrc: "",
|
DescriptionSrc: "",
|
||||||
Camera: nil,
|
Camera: CameraFixtures.Pointer("canon-eos-6d"),
|
||||||
Lens: nil,
|
Lens: LensFixtures.Pointer("lens-f-380"),
|
||||||
Location: nil,
|
Location: &LocationFixturesMexico,
|
||||||
Place: nil,
|
Place: PlaceFixtures.Pointer("teotihuacan"),
|
||||||
Links: []Link{},
|
Links: []Link{},
|
||||||
Keywords: []Keyword{},
|
Keywords: []Keyword{},
|
||||||
Albums: []Album{},
|
Albums: []Album{},
|
||||||
|
@ -905,10 +905,10 @@ var PhotoFixtures = PhotoMap{
|
||||||
PhotoMonth: 0,
|
PhotoMonth: 0,
|
||||||
Description: DescriptionFixtures.Get("lake", 1000015),
|
Description: DescriptionFixtures.Get("lake", 1000015),
|
||||||
DescriptionSrc: "location",
|
DescriptionSrc: "location",
|
||||||
Camera: nil,
|
Camera: CameraFixtures.Pointer("canon-eos-6d"),
|
||||||
Lens: nil,
|
Lens: LensFixtures.Pointer("lens-f-380"),
|
||||||
Location: nil,
|
Location: &LocationFixturesMexico,
|
||||||
Place: nil,
|
Place: PlaceFixtures.Pointer("teotihuacan"),
|
||||||
Links: []Link{},
|
Links: []Link{},
|
||||||
Keywords: []Keyword{},
|
Keywords: []Keyword{},
|
||||||
Albums: []Album{},
|
Albums: []Album{},
|
||||||
|
|
Loading…
Reference in a new issue