Backend: Add test fixtures

This commit is contained in:
Theresa Gresch 2020-05-01 14:13:59 +02:00
parent 9e343cef04
commit 6edb578b34
7 changed files with 78 additions and 75 deletions

View file

@ -1,15 +1,14 @@
package entity package entity
import ( import (
"github.com/jinzhu/gorm"
"time" "time"
) )
var AlbumFixtures = map[string]Album{ var AlbumFixtures = map[string]Album{
"christmas2030": { "christmas2030": {
ID: 1000000, ID: 1000000,
CoverUUID: nil, CoverUUID: "",
AlbumUUID: "aq9lxuqxpogaaba7", AlbumUUID: "at9lxuqxpogaaba7",
AlbumSlug: "christmas2030", AlbumSlug: "christmas2030",
AlbumName: "Christmas2030", AlbumName: "Christmas2030",
AlbumDescription: "Wonderful christmas", AlbumDescription: "Wonderful christmas",
@ -24,8 +23,8 @@ var AlbumFixtures = map[string]Album{
}, },
"holiday-2030": { "holiday-2030": {
ID: 1000001, ID: 1000001,
CoverUUID: nil, CoverUUID: "",
AlbumUUID: "aq9lxuqxpogaaba8", AlbumUUID: "at9lxuqxpogaaba8",
AlbumSlug: "holiday-2030", AlbumSlug: "holiday-2030",
AlbumName: "Holiday2030", AlbumName: "Holiday2030",
AlbumDescription: "Wonderful christmas", AlbumDescription: "Wonderful christmas",
@ -40,8 +39,8 @@ var AlbumFixtures = map[string]Album{
}, },
"berlin-2019": { "berlin-2019": {
ID: 1000002, ID: 1000002,
CoverUUID: nil, CoverUUID: "",
AlbumUUID: "aq9lxuqxpogaaba9", AlbumUUID: "at9lxuqxpogaaba9",
AlbumSlug: "berlin-2019", AlbumSlug: "berlin-2019",
AlbumName: "Berlin2019", AlbumName: "Berlin2019",
AlbumDescription: "Wonderful christmas", AlbumDescription: "Wonderful christmas",
@ -56,9 +55,12 @@ var AlbumFixtures = map[string]Album{
}, },
} }
var AlbumFixtureHoliday2030 = AlbumFixtures["holiday-2030"]
var AlbumFixtureBerlin2019 = AlbumFixtures["berlin-2019"]
// CreateAlbumFixtures inserts known entities into the database for testing. // CreateAlbumFixtures inserts known entities into the database for testing.
func CreateAlbumFixtures(db *gorm.DB) { func CreateAlbumFixtures() {
for _, entity := range AlbumFixtures { for _, entity := range AlbumFixtures {
db.Create(&entity) Db().Create(&entity)
} }
} }

View file

@ -2,8 +2,6 @@ package entity
import ( import (
"time" "time"
"github.com/jinzhu/gorm"
) )
var CameraFixtures = map[string]Camera{ var CameraFixtures = map[string]Camera{
@ -84,8 +82,8 @@ var CameraFixtures = map[string]Camera{
var CameraFixtureEOS6D = CameraFixtures["canon-eos-6d"] var CameraFixtureEOS6D = CameraFixtures["canon-eos-6d"]
// CreateCameraFixtures inserts known entities into the database for testing. // CreateCameraFixtures inserts known entities into the database for testing.
func CreateCameraFixtures(db *gorm.DB) { func CreateCameraFixtures() {
for _, entity := range CameraFixtures { for _, entity := range CameraFixtures {
db.Create(&entity) Db().Create(&entity)
} }
} }

View file

@ -1,9 +1,5 @@
package entity package entity
import (
"github.com/jinzhu/gorm"
)
var CountryFixtures = map[string]Country{ var CountryFixtures = map[string]Country{
"apple-iphone-se": { "apple-iphone-se": {
ID: "de", ID: "de",
@ -18,8 +14,8 @@ var CountryFixtures = map[string]Country{
} }
// CreateCountryFixtures inserts known entities into the database for testing. // CreateCountryFixtures inserts known entities into the database for testing.
func CreateCountryFixtures(db *gorm.DB) { func CreateCountryFixtures() {
for _, entity := range CountryFixtures { for _, entity := range CountryFixtures {
db.Create(&entity) Db().Create(&entity)
} }
} }

View file

@ -9,8 +9,8 @@ var FileFixtures = map[string]File{
ID: 1000000, ID: 1000000,
Photo: &PhotoFixture19800101_000002_D640C559, Photo: &PhotoFixture19800101_000002_D640C559,
PhotoID: 1000000, PhotoID: 1000000,
PhotoUUID: "1jxf3jfn2k", PhotoUUID: "pt9jtdre2lvl0yh7",
FileUUID: "fq8es39w45bnlqdw", FileUUID: "ft8es39w45bnlqdw",
FileName: "exampleFileName.jpg", FileName: "exampleFileName.jpg",
OriginalName: "exampleFileNameOriginal.jpg", OriginalName: "exampleFileNameOriginal.jpg",
FileHash: "2cad9168fa6acc5c5c2965ddf6ec465ca42fd818", FileHash: "2cad9168fa6acc5c5c2965ddf6ec465ca42fd818",
@ -48,8 +48,8 @@ var FileFixtures = map[string]File{
ID: 1000001, ID: 1000001,
Photo: &PhotoFixturePhoto01, Photo: &PhotoFixturePhoto01,
PhotoID: 1000001, PhotoID: 1000001,
PhotoUUID: "1jxf3jfn2k", PhotoUUID: "pt9jtdre2lvl0yh8",
FileUUID: "rq8es39w45bnlqdw", FileUUID: "ft9es39w45bnlqdw",
FileName: "exampleDNGFile.dng", FileName: "exampleDNGFile.dng",
OriginalName: "exampleDNGFile.dng", OriginalName: "exampleDNGFile.dng",
FileHash: "3cad9168fa6acc5c5c2965ddf6ec465ca42fd818", FileHash: "3cad9168fa6acc5c5c2965ddf6ec465ca42fd818",
@ -87,8 +87,8 @@ var FileFixtures = map[string]File{
ID: 1000002, ID: 1000002,
Photo: &PhotoFixturePhoto01, Photo: &PhotoFixturePhoto01,
PhotoID: 1000001, PhotoID: 1000001,
PhotoUUID: "1jxf3jfn2k", PhotoUUID: "pt9jtdre2lvl0yh8",
FileUUID: "9q8es39w45bnlqdw", FileUUID: "ft1es39w45bnlqdw",
FileName: "exampleXmpFile.xmp", FileName: "exampleXmpFile.xmp",
OriginalName: "exampleXmpFile.xmp", OriginalName: "exampleXmpFile.xmp",
FileHash: "ocad9168fa6acc5c5c2965ddf6ec465ca42fd818", FileHash: "ocad9168fa6acc5c5c2965ddf6ec465ca42fd818",
@ -126,8 +126,8 @@ var FileFixtures = map[string]File{
ID: 1000003, ID: 1000003,
Photo: &PhotoFixturePhoto04, Photo: &PhotoFixturePhoto04,
PhotoID: 1000004, PhotoID: 1000004,
PhotoUUID: "pq9jtdre2lvl0y11", PhotoUUID: "pt9jtdre2lvl0y11",
FileUUID: "pq8es39w45bnlqdw", FileUUID: "ft2es39w45bnlqdw",
FileName: "bridge.jpg", FileName: "bridge.jpg",
OriginalName: "bridgeOriginal.jpg", OriginalName: "bridgeOriginal.jpg",
FileHash: "pcad9168fa6acc5c5c2965ddf6ec465ca42fd818", FileHash: "pcad9168fa6acc5c5c2965ddf6ec465ca42fd818",
@ -165,8 +165,8 @@ var FileFixtures = map[string]File{
ID: 1000004, ID: 1000004,
Photo: &PhotoFixturePhoto05, Photo: &PhotoFixturePhoto05,
PhotoID: 1000005, PhotoID: 1000005,
PhotoUUID: "pq9jtdre2lvl0y12", PhotoUUID: "pt9jtdre2lvl0y12",
FileUUID: "aq8es39w45bnlqdw", FileUUID: "ft3es39w45bnlqdw",
FileName: "reunion.jpg", FileName: "reunion.jpg",
OriginalName: "reunionOriginal.jpg", OriginalName: "reunionOriginal.jpg",
FileHash: "acad9168fa6acc5c5c2965ddf6ec465ca42fd818", FileHash: "acad9168fa6acc5c5c2965ddf6ec465ca42fd818",

View file

@ -61,7 +61,7 @@ var LabelFixtures = map[string]Label{
LabelUUID: "lt9k3pw1wowuy3c5", LabelUUID: "lt9k3pw1wowuy3c5",
LabelSlug: "cow", LabelSlug: "cow",
CustomSlug: "kuh", CustomSlug: "kuh",
LabelName: "Cow", LabelName: "COW",
LabelPriority: -1, LabelPriority: -1,
LabelFavorite: true, LabelFavorite: true,
LabelDescription: "", LabelDescription: "",
@ -75,6 +75,10 @@ var LabelFixtures = map[string]Label{
}, },
} }
var LabelFixtureLandscape = LabelFixtures["landscape"]
var LabelFixtureFlower = LabelFixtures["flower"]
var LabelFixtureCake = LabelFixtures["cake"]
// CreateLabelFixtures inserts known entities into the database for testing. // CreateLabelFixtures inserts known entities into the database for testing.
func CreateLabelFixtures() { func CreateLabelFixtures() {
for _, entity := range LabelFixtures { for _, entity := range LabelFixtures {

View file

@ -4,8 +4,8 @@ import "time"
var PhotoAlbumFixtures = map[string]PhotoAlbum{ var PhotoAlbumFixtures = map[string]PhotoAlbum{
"1": { "1": {
PhotoUUID: "1jxf3jfn2k", PhotoUUID: "pt9jtdre2lvl0yh7",
AlbumUUID: "pq9jtdre2lvl0yh7", AlbumUUID: "at9lxuqxpogaaba8",
Order: 0, Order: 0,
CreatedAt: time.Date(2020, 3, 6, 2, 6, 51, 0, time.UTC), CreatedAt: time.Date(2020, 3, 6, 2, 6, 51, 0, time.UTC),
UpdatedAt: time.Date(2020, 3, 28, 14, 6, 0, 0, time.UTC), UpdatedAt: time.Date(2020, 3, 28, 14, 6, 0, 0, time.UTC),
@ -13,8 +13,8 @@ var PhotoAlbumFixtures = map[string]PhotoAlbum{
Album: &AlbumFixtureHoliday2030, Album: &AlbumFixtureHoliday2030,
}, },
"2": { "2": {
PhotoUUID: "pq9jtdre2lvl0y11", PhotoUUID: "pt9jtdre2lvl0y11",
AlbumUUID: "aq9lxuqxpogaaba9", AlbumUUID: "at9lxuqxpogaaba9",
Order: 0, Order: 0,
CreatedAt: time.Date(2020, 2, 6, 2, 6, 51, 0, time.UTC), CreatedAt: time.Date(2020, 2, 6, 2, 6, 51, 0, time.UTC),
UpdatedAt: time.Date(2020, 4, 28, 14, 6, 0, 0, time.UTC), UpdatedAt: time.Date(2020, 4, 28, 14, 6, 0, 0, time.UTC),

View file

@ -2,14 +2,12 @@ package entity
import ( import (
"time" "time"
"github.com/jinzhu/gorm"
) )
var PhotoFixtures = map[string]Photo{ var PhotoFixtures = map[string]Photo{
"19800101_000002_D640C559": { "19800101_000002_D640C559": {
ID: 1000000, ID: 1000000,
PhotoUUID: "pq9jtdre2lvl0yh7", PhotoUUID: "pt9jtdre2lvl0yh7",
TakenAt: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC), TakenAt: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC),
TakenAtLocal: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC), TakenAtLocal: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC),
TakenSrc: "exif", TakenSrc: "exif",
@ -25,14 +23,14 @@ var PhotoFixtures = map[string]Photo{
PhotoLat: 48.519234, PhotoLat: 48.519234,
PhotoLng: 9.057997, PhotoLng: 9.057997,
PhotoAltitude: 0, PhotoAltitude: 0,
PhotoIso: nil, PhotoIso: 0,
PhotoFocalLength: nil, PhotoFocalLength: 0,
PhotoFNumber: nil, PhotoFNumber: 0,
PhotoExposure: "", PhotoExposure: "",
CameraID: nil, CameraID: 0,
CameraSerial: "", CameraSerial: "",
CameraSrc: "", CameraSrc: "",
LensID: nil, LensID: 0,
PlaceID: "zz", PlaceID: "zz",
LocationID: "", LocationID: "",
LocationSrc: "", LocationSrc: "",
@ -58,7 +56,7 @@ var PhotoFixtures = map[string]Photo{
}, },
"Photo01": { "Photo01": {
ID: 1000001, ID: 1000001,
PhotoUUID: "pq9jtdre2lvl0yh8", PhotoUUID: "pt9jtdre2lvl0yh8",
TakenAt: time.Date(2008, 1, 1, 2, 0, 0, 0, time.UTC), TakenAt: time.Date(2008, 1, 1, 2, 0, 0, 0, time.UTC),
TakenAtLocal: time.Date(2008, 1, 1, 2, 0, 0, 0, time.UTC), TakenAtLocal: time.Date(2008, 1, 1, 2, 0, 0, 0, time.UTC),
TakenSrc: "exif", TakenSrc: "exif",
@ -68,20 +66,20 @@ var PhotoFixtures = map[string]Photo{
PhotoName: "Photo01", PhotoName: "Photo01",
PhotoQuality: 3, PhotoQuality: 3,
PhotoResolution: 2, PhotoResolution: 2,
PhotoFavorite: false, PhotoFavorite: true,
PhotoPrivate: false, PhotoPrivate: false,
PhotoStory: false, PhotoStory: false,
PhotoLat: 48.519234, PhotoLat: 48.519234,
PhotoLng: 9.057997, PhotoLng: 9.057997,
PhotoAltitude: 0, PhotoAltitude: 0,
PhotoIso: nil, PhotoIso: 0,
PhotoFocalLength: nil, PhotoFocalLength: 0,
PhotoFNumber: nil, PhotoFNumber: 0,
PhotoExposure: "", PhotoExposure: "",
CameraID: nil, CameraID: 0,
CameraSerial: "", CameraSerial: "",
CameraSrc: "", CameraSrc: "",
LensID: nil, LensID: 0,
PlaceID: "zz", PlaceID: "zz",
LocationID: "", LocationID: "",
LocationSrc: "", LocationSrc: "",
@ -107,7 +105,7 @@ var PhotoFixtures = map[string]Photo{
}, },
"Photo02": { "Photo02": {
ID: 1000002, ID: 1000002,
PhotoUUID: "pq9jtdre2lvl0yh9", PhotoUUID: "pt9jtdre2lvl0yh9",
TakenAt: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC), TakenAt: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC),
TakenAtLocal: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC), TakenAtLocal: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC),
TakenSrc: "exif", TakenSrc: "exif",
@ -123,14 +121,14 @@ var PhotoFixtures = map[string]Photo{
PhotoLat: 48.519234, PhotoLat: 48.519234,
PhotoLng: 9.057997, PhotoLng: 9.057997,
PhotoAltitude: 0, PhotoAltitude: 0,
PhotoIso: nil, PhotoIso: 0,
PhotoFocalLength: nil, PhotoFocalLength: 0,
PhotoFNumber: nil, PhotoFNumber: 0,
PhotoExposure: "", PhotoExposure: "",
CameraID: nil, CameraID: 0,
CameraSerial: "", CameraSerial: "",
CameraSrc: "", CameraSrc: "",
LensID: nil, LensID: 0,
PlaceID: "zz", PlaceID: "zz",
LocationID: "", LocationID: "",
LocationSrc: "", LocationSrc: "",
@ -156,7 +154,7 @@ var PhotoFixtures = map[string]Photo{
}, },
"Photo03": { "Photo03": {
ID: 1000003, ID: 1000003,
PhotoUUID: "pq9jtdre2lvl0yh0", PhotoUUID: "pt9jtdre2lvl0yh0",
TakenAt: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC), TakenAt: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC),
TakenAtLocal: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC), TakenAtLocal: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC),
TakenSrc: "exif", TakenSrc: "exif",
@ -172,14 +170,14 @@ var PhotoFixtures = map[string]Photo{
PhotoLat: 48.519234, PhotoLat: 48.519234,
PhotoLng: 9.057997, PhotoLng: 9.057997,
PhotoAltitude: 0, PhotoAltitude: 0,
PhotoIso: nil, PhotoIso: 0,
PhotoFocalLength: nil, PhotoFocalLength: 0,
PhotoFNumber: nil, PhotoFNumber: 0,
PhotoExposure: "", PhotoExposure: "",
CameraID: nil, CameraID: 0,
CameraSerial: "", CameraSerial: "",
CameraSrc: "", CameraSrc: "",
LensID: nil, LensID: 0,
PlaceID: "zz", PlaceID: "zz",
LocationID: "", LocationID: "",
LocationSrc: "", LocationSrc: "",
@ -205,7 +203,7 @@ var PhotoFixtures = map[string]Photo{
}, },
"Photo04": { "Photo04": {
ID: 1000004, ID: 1000004,
PhotoUUID: "pq9jtdre2lvl0y11", PhotoUUID: "pt9jtdre2lvl0y11",
TakenAt: time.Date(2014, 7, 17, 15, 42, 12, 0, time.UTC), TakenAt: time.Date(2014, 7, 17, 15, 42, 12, 0, time.UTC),
TakenAtLocal: time.Date(2014, 7, 17, 15, 42, 12, 0, time.UTC), TakenAtLocal: time.Date(2014, 7, 17, 15, 42, 12, 0, time.UTC),
TakenSrc: "exif", TakenSrc: "exif",
@ -221,14 +219,14 @@ var PhotoFixtures = map[string]Photo{
PhotoLat: 48.519234, PhotoLat: 48.519234,
PhotoLng: 9.057997, PhotoLng: 9.057997,
PhotoAltitude: 0, PhotoAltitude: 0,
PhotoIso: nil, PhotoIso: 0,
PhotoFocalLength: nil, PhotoFocalLength: 0,
PhotoFNumber: nil, PhotoFNumber: 0,
PhotoExposure: "", PhotoExposure: "",
CameraID: nil, CameraID: 0,
CameraSerial: "", CameraSerial: "",
CameraSrc: "", CameraSrc: "",
LensID: nil, LensID: 0,
PlaceID: "zz", PlaceID: "zz",
LocationID: "", LocationID: "",
LocationSrc: "", LocationSrc: "",
@ -254,7 +252,7 @@ var PhotoFixtures = map[string]Photo{
}, },
"Photo05": { "Photo05": {
ID: 1000005, ID: 1000005,
PhotoUUID: "pq9jtdre2lvl0y12", PhotoUUID: "pt9jtdre2lvl0y12",
TakenAt: time.Date(2015, 11, 11, 9, 7, 18, 0, time.UTC), TakenAt: time.Date(2015, 11, 11, 9, 7, 18, 0, time.UTC),
TakenAtLocal: time.Date(2015, 11, 11, 9, 7, 18, 0, time.UTC), TakenAtLocal: time.Date(2015, 11, 11, 9, 7, 18, 0, time.UTC),
TakenSrc: "exif", TakenSrc: "exif",
@ -270,14 +268,14 @@ var PhotoFixtures = map[string]Photo{
PhotoLat: -21.342636, PhotoLat: -21.342636,
PhotoLng: 55.466944, PhotoLng: 55.466944,
PhotoAltitude: 0, PhotoAltitude: 0,
PhotoIso: nil, PhotoIso: 0,
PhotoFocalLength: nil, PhotoFocalLength: 0,
PhotoFNumber: nil, PhotoFNumber: 0,
PhotoExposure: "", PhotoExposure: "",
CameraID: nil, CameraID: 0,
CameraSerial: "", CameraSerial: "",
CameraSrc: "", CameraSrc: "",
LensID: nil, LensID: 0,
PlaceID: "zz", PlaceID: "zz",
LocationID: "", LocationID: "",
LocationSrc: "", LocationSrc: "",
@ -303,9 +301,14 @@ var PhotoFixtures = map[string]Photo{
}, },
} }
var PhotoFixture19800101_000002_D640C559 = PhotoFixtures["19800101_000002_D640C559"]
var PhotoFixturePhoto04 = PhotoFixtures["Photo04"]
var PhotoFixturePhoto01 = PhotoFixtures["Photo01"]
var PhotoFixturePhoto05 = PhotoFixtures["Photo05"]
// CreatePhotoFixtures inserts known entities into the database for testing. // CreatePhotoFixtures inserts known entities into the database for testing.
func CreatePhotoFixtures(db *gorm.DB) { func CreatePhotoFixtures() {
for _, entity := range PhotoFixtures { for _, entity := range PhotoFixtures {
db.Create(&entity) Db().Create(&entity)
} }
} }