Backend: Add tests fixtures

This commit is contained in:
Theresa Gresch 2020-05-13 19:46:49 +02:00
parent bd59dc2564
commit c0a2da8bab
4 changed files with 68 additions and 21 deletions

View file

@ -22,11 +22,11 @@ var FileFixtures = map[string]File{
FileSidecar: false,
FileVideo: false,
FileMissing: false,
FileDuplicate: false,
FilePortrait: false,
FileDuplicate: true,
FilePortrait: true,
FileWidth: 3648,
FileHeight: 2736,
FileOrientation: 1,
FileOrientation: 0,
FileAspectRatio: 1.33333,
FileMainColor: "green",
FileColors: "929299991",
@ -191,7 +191,7 @@ var FileFixtures = map[string]File{
FileColors: "266111000",
FileLuminance: "DC42844C8",
FileDiff: 800,
FileChroma: 26,
FileChroma: 4,
FileNotes: "",
FileError: "",
Share: []FileShare{},

View file

@ -18,4 +18,5 @@ func CreateTestFixtures() {
CreatePlaceFixtures()
CreateFileShareFixtures()
CreateFileSyncFixtures()
CreateLensFixtures()
}

View 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)
}
}

View file

@ -45,7 +45,7 @@ var PhotoFixtures = PhotoMap{
PhotoAltitude: 0,
PhotoIso: 0,
PhotoFocalLength: 0,
PhotoFNumber: 0,
PhotoFNumber: 5,
PhotoExposure: "",
CameraID: 0,
CameraSerial: "",
@ -61,9 +61,9 @@ var PhotoFixtures = PhotoMap{
Description: DescriptionFixtures.Get("lake", 1000000),
DescriptionSrc: "",
Camera: CameraFixtures.Pointer("canon-eos-6d"),
Lens: nil,
Lens: LensFixtures.Pointer("lens-f-380"),
Location: nil,
Place: nil,
Place: PlaceFixtures.Pointer("teotihuacan"),
Links: []Link{},
Keywords: []Keyword{},
Albums: []Album{
@ -115,7 +115,7 @@ var PhotoFixtures = PhotoMap{
Description: Description{},
DescriptionSrc: "",
Camera: CameraFixtures.Pointer("canon-eos-6d"),
Lens: nil,
Lens: LensFixtures.Pointer("lens-f-380"),
Location: nil,
Place: nil,
Links: []Link{},
@ -164,7 +164,7 @@ var PhotoFixtures = PhotoMap{
Description: Description{},
DescriptionSrc: "",
Camera: nil,
Lens: nil,
Lens: LensFixtures.Pointer("lens-f-380"),
Location: nil,
Place: nil,
Links: []Link{},
@ -264,10 +264,10 @@ var PhotoFixtures = PhotoMap{
PhotoMonth: 7,
Description: Description{},
DescriptionSrc: "",
Camera: nil,
Lens: nil,
Location: nil,
Place: nil,
Camera: CameraFixtures.Pointer("canon-eos-6d"),
Lens: LensFixtures.Pointer("lens-f-380"),
Location: &LocationFixturesMexico,
Place: PlaceFixtures.Pointer("teotihuacan"),
Links: []Link{},
Keywords: []Keyword{
KeywordFixtures.Get("bridge"),
@ -317,10 +317,10 @@ var PhotoFixtures = PhotoMap{
PhotoMonth: 7,
Description: Description{},
DescriptionSrc: "",
Camera: nil,
Lens: nil,
Location: nil,
Place: nil,
Camera: CameraFixtures.Pointer("canon-eos-6d"),
Lens: LensFixtures.Pointer("lens-f-380"),
Location: &LocationFixturesMexico,
Place: PlaceFixtures.Pointer("teotihuacan"),
Links: []Link{},
Keywords: []Keyword{},
Albums: []Album{},
@ -905,10 +905,10 @@ var PhotoFixtures = PhotoMap{
PhotoMonth: 0,
Description: DescriptionFixtures.Get("lake", 1000015),
DescriptionSrc: "location",
Camera: nil,
Lens: nil,
Location: nil,
Place: nil,
Camera: CameraFixtures.Pointer("canon-eos-6d"),
Lens: LensFixtures.Pointer("lens-f-380"),
Location: &LocationFixturesMexico,
Place: PlaceFixtures.Pointer("teotihuacan"),
Links: []Link{},
Keywords: []Keyword{},
Albums: []Album{},