Tests: Refactor unit tests after uid change #4560

This commit is contained in:
graciousgrey 2024-10-21 13:16:06 +02:00
parent e561b222c5
commit 689622dc7e
8 changed files with 274 additions and 9 deletions

View file

@ -112,6 +112,15 @@ var CellFixtures = CellMap{
CreatedAt: Now(),
UpdatedAt: Now(),
},
"California": {
ID: s2.TokenPrefix + "80dc03fbc914",
PlaceID: PlaceFixtures.Get("California").ID,
Place: PlaceFixtures.Pointer("California"),
CellName: "California Beach",
CellCategory: "",
CreatedAt: Now(),
UpdatedAt: Now(),
},
}
// CreateCellFixtures inserts known entities into the database for testing.

View file

@ -2842,6 +2842,132 @@ var FileFixtures = FileMap{
UpdatedIn: 935962,
DeletedAt: nil,
},
"photo53.jpg": {
ID: 1000070,
Photo: PhotoFixtures.Pointer("photo53"),
PhotoID: PhotoFixtures.Pointer("photo53").ID,
PhotoUID: PhotoFixtures.Pointer("photo53").PhotoUID,
InstanceID: "",
FileUID: "fs6sg6bw15bnl357",
FileName: "2023/holiday/photo53.jpg",
FileRoot: RootOriginals,
OriginalName: "",
FileHash: "pcad9168fa6acc5c5c2965adf6ec465ca42fd7777",
FileSize: 921858,
FileCodec: "jpeg",
FileType: "jpg",
MediaType: media.Image.String(),
FileMime: "image/jpg",
FilePrimary: true,
FileSidecar: false,
FileVideo: false,
FileMissing: false,
FilePortrait: true,
FileDuration: 0,
FileWidth: 1200,
FileHeight: 1600,
FileOrientation: 6,
FileProjection: "",
FileAspectRatio: 0.75,
FileMainColor: "magenta",
FileColors: "225221C1E",
FileLuminance: "DC42844C8",
FileDiff: 986,
FileChroma: 32,
FileError: "",
Share: []FileShare{},
Sync: []FileSync{},
ModTime: time.Date(2023, 11, 13, 9, 7, 18, 0, time.UTC).Unix(),
CreatedAt: time.Date(2023, 11, 13, 9, 7, 18, 0, time.UTC),
CreatedIn: 935962,
UpdatedAt: time.Date(2023, 11, 13, 9, 7, 18, 0, time.UTC),
UpdatedIn: 935962,
DeletedAt: nil,
},
"photo54.jpg": {
ID: 1000071,
Photo: PhotoFixtures.Pointer("photo54"),
PhotoID: PhotoFixtures.Pointer("photo54").ID,
PhotoUID: PhotoFixtures.Pointer("photo54").PhotoUID,
InstanceID: "",
FileUID: "fs6sg6bw15bnl358",
FileName: "2023/holiday/photo54.jpg",
FileRoot: RootOriginals,
OriginalName: "",
FileHash: "pcad9168fa6acc5c5c2965adf6ec465ca42fd8888",
FileSize: 921858,
FileCodec: "jpeg",
FileType: "jpg",
MediaType: media.Image.String(),
FileMime: "image/jpg",
FilePrimary: true,
FileSidecar: false,
FileVideo: false,
FileMissing: false,
FilePortrait: true,
FileDuration: 0,
FileWidth: 1200,
FileHeight: 1600,
FileOrientation: 6,
FileProjection: "",
FileAspectRatio: 0.75,
FileMainColor: "magenta",
FileColors: "225221C1E",
FileLuminance: "DC42844C8",
FileDiff: 986,
FileChroma: 32,
FileError: "",
Share: []FileShare{},
Sync: []FileSync{},
ModTime: time.Date(2023, 11, 12, 9, 7, 18, 0, time.UTC).Unix(),
CreatedAt: time.Date(2023, 11, 12, 9, 7, 18, 0, time.UTC),
CreatedIn: 935962,
UpdatedAt: time.Date(2023, 11, 12, 9, 7, 18, 0, time.UTC),
UpdatedIn: 935962,
DeletedAt: nil,
},
"photo54 (1).jpg": {
ID: 1000072,
Photo: PhotoFixtures.Pointer("photo54"),
PhotoID: PhotoFixtures.Pointer("photo54").ID,
PhotoUID: PhotoFixtures.Pointer("photo54").PhotoUID,
InstanceID: "",
FileUID: "fs6sg6bw15bnl359",
FileName: "2023/holiday/photo54 (1).jpg",
FileRoot: RootOriginals,
OriginalName: "",
FileHash: "pcad9168fa6acc5c5c2965adf6ec465ca42fd9999",
FileSize: 921858,
FileCodec: "jpeg",
FileType: "jpg",
MediaType: media.Image.String(),
FileMime: "image/jpg",
FilePrimary: false,
FileSidecar: false,
FileVideo: false,
FileMissing: false,
FilePortrait: true,
FileDuration: 0,
FileWidth: 1200,
FileHeight: 1600,
FileOrientation: 6,
FileProjection: "",
FileAspectRatio: 0.75,
FileMainColor: "magenta",
FileColors: "225221C1E",
FileLuminance: "DC42844C8",
FileDiff: 986,
FileChroma: 32,
FileError: "",
Share: []FileShare{},
Sync: []FileSync{},
ModTime: time.Date(2023, 11, 12, 9, 7, 18, 0, time.UTC).Unix(),
CreatedAt: time.Date(2023, 11, 12, 9, 7, 18, 0, time.UTC),
CreatedIn: 935962,
UpdatedAt: time.Date(2023, 11, 12, 9, 7, 18, 0, time.UTC),
UpdatedIn: 935962,
DeletedAt: nil,
},
}
var FileFixturesExampleJPG = FileFixtures["exampleFileName.jpg"]

View file

@ -3419,6 +3419,124 @@ var PhotoFixtures = PhotoMap{
PhotoStack: 0,
PhotoFaces: 0,
},
"photo53": { //JPG, Geo from metadata, indexed
ID: 1000054,
PhotoUID: "ps6sg6byk7wrbk46",
TakenAt: time.Date(2023, 11, 13, 9, 7, 18, 0, time.UTC),
TakenAtLocal: time.Date(2023, 11, 13, 9, 7, 18, 0, time.UTC),
TakenSrc: SrcMeta,
PhotoType: "image",
TypeSrc: "",
PhotoTitle: "California 1",
TitleSrc: SrcManual,
PhotoDescription: "",
DescriptionSrc: "",
PhotoPath: "2023/holiday",
PhotoName: "photo53",
OriginalName: "",
PhotoFavorite: false,
PhotoPrivate: false,
PhotoScan: false,
PhotoPanorama: false,
TimeZone: "America/Los_Angeles",
Place: CellFixtures.Pointer("California").Place,
PlaceID: CellFixtures.Pointer("California").Place.ID,
PlaceSrc: "meta",
Cell: CellFixtures.Pointer("California"),
CellID: CellFixtures.Pointer("California").ID,
CellAccuracy: 0,
PhotoAltitude: 3,
PhotoLat: 32.848623333333336,
PhotoLng: -117.275965,
PhotoCountry: CellFixtures.Pointer("California").Place.CountryCode(),
PhotoYear: 2023,
PhotoMonth: 11,
PhotoDay: 13,
PhotoIso: 0,
PhotoExposure: "",
PhotoFocalLength: 0,
PhotoFNumber: 0,
PhotoQuality: 5,
PhotoResolution: 0,
Camera: CameraFixtures.Pointer("canon-eos-6d"),
CameraID: CameraFixtures.Pointer("canon-eos-6d").ID,
CameraSerial: "",
CameraSrc: "",
Lens: LensFixtures.Pointer("lens-f-380"),
LensID: LensFixtures.Pointer("lens-f-380").ID,
Details: DetailsFixtures.Pointer("lake", 1000015),
Keywords: []Keyword{},
Albums: []Album{},
Files: []File{},
Labels: []PhotoLabel{},
CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
UpdatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
EditedAt: nil,
CheckedAt: &checkedTime,
DeletedAt: nil,
PhotoColor: 14,
PhotoStack: 0,
PhotoFaces: 0,
},
"photo54": { //JPG + JPG, Geo from metadata, indexed
ID: 1000055,
PhotoUID: "ps6sg6byk7wrbk47",
TakenAt: time.Date(2023, 11, 12, 9, 7, 18, 0, time.UTC),
TakenAtLocal: time.Date(2023, 11, 12, 9, 7, 18, 0, time.UTC),
TakenSrc: SrcMeta,
PhotoType: "image",
TypeSrc: "",
PhotoTitle: "California Stack",
TitleSrc: SrcManual,
PhotoDescription: "",
DescriptionSrc: "",
PhotoPath: "2023/holiday",
PhotoName: "photo54",
OriginalName: "",
PhotoFavorite: false,
PhotoPrivate: false,
PhotoScan: false,
PhotoPanorama: false,
TimeZone: "America/Los_Angeles",
Place: CellFixtures.Pointer("California").Place,
PlaceID: CellFixtures.Pointer("California").Place.ID,
PlaceSrc: "meta",
Cell: CellFixtures.Pointer("California"),
CellID: CellFixtures.Pointer("California").ID,
CellAccuracy: 0,
PhotoAltitude: 3,
PhotoLat: 32.848623333333336,
PhotoLng: -117.275965,
PhotoCountry: CellFixtures.Pointer("California").Place.CountryCode(),
PhotoYear: 2023,
PhotoMonth: 11,
PhotoDay: 12,
PhotoIso: 0,
PhotoExposure: "",
PhotoFocalLength: 0,
PhotoFNumber: 0,
PhotoQuality: 5,
PhotoResolution: 0,
Camera: CameraFixtures.Pointer("canon-eos-6d"),
CameraID: CameraFixtures.Pointer("canon-eos-6d").ID,
CameraSerial: "",
CameraSrc: "",
Lens: LensFixtures.Pointer("lens-f-380"),
LensID: LensFixtures.Pointer("lens-f-380").ID,
Details: DetailsFixtures.Pointer("lake", 1000015),
Keywords: []Keyword{},
Albums: []Album{},
Files: []File{},
Labels: []PhotoLabel{},
CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
UpdatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
EditedAt: nil,
CheckedAt: &checkedTime,
DeletedAt: nil,
PhotoColor: 14,
PhotoStack: 0,
PhotoFaces: 0,
},
}
// CreatePhotoFixtures inserts known entities into the database for testing.

View file

@ -120,6 +120,18 @@ var PlaceFixtures = PlacesMap{
CreatedAt: Now(),
UpdatedAt: Now(),
},
"California": {
ID: s2.TokenPrefix + "80dc03fbc914",
PlaceLabel: "California",
PlaceCity: "",
PlaceState: "California",
PlaceCountry: "us",
PlaceKeywords: "",
PlaceFavorite: false,
PhotoCount: 3,
CreatedAt: Now(),
UpdatedAt: Now(),
},
}
// CreatePlaceFixtures inserts known entities into the database for testing.

View file

@ -21,7 +21,7 @@ func TestFileSelection(t *testing.T) {
folders := form.Selection{Albums: []string{"as6sg6bipogaaba1", "as6sg6bipogaabj8"}}
states := form.Selection{Albums: []string{"as6sg6bipogaab11", "as6sg6bipotaab12", "as6sg6bipotaab19"}}
states := form.Selection{Albums: []string{"as6sg6bipogaab11", "as6sg6bipotaab12", "asjv2cw2eikl3cb3"}}
many := form.Selection{
Files: []string{"fs6sg6bw45bnlqdw"},

View file

@ -16,7 +16,7 @@ func TestPhotoSelection(t *testing.T) {
folders := form.Selection{Albums: []string{"as6sg6bipogaaba1", "as6sg6bipogaabj8"}}
states := form.Selection{Albums: []string{"as6sg6bipogaab11", "as6sg6bipotaab12", "as6sg6bipotaab19"}}
states := form.Selection{Albums: []string{"as6sg6bipogaab11", "as6sg6bipotaab12", "asjv2cw2eikl3cb3"}}
t.Run("no items selected", func(t *testing.T) {
f := form.Selection{
@ -79,7 +79,7 @@ func TestPhotoSelection(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, 1, len(r))
assert.Equal(t, 2, len(r))
assert.IsType(t, entity.Photos{}, r)
})
}

View file

@ -55,7 +55,7 @@ func TestPhotosFilterTime(t *testing.T) {
// t.Logf("Updated: %#v", photos)
assert.GreaterOrEqual(t, 49, len(photos))
assert.GreaterOrEqual(t, 51, len(photos))
})
t.Run("Edited", func(t *testing.T) {
var f form.SearchPhotos
@ -147,6 +147,6 @@ func TestPhotosFilterTime(t *testing.T) {
// t.Logf("After: %#v", photos)
assert.GreaterOrEqual(t, 2, len(photos))
assert.GreaterOrEqual(t, 4, len(photos))
})
}

View file

@ -701,9 +701,9 @@ func TestPhotos(t *testing.T) {
assert.LessOrEqual(t, 2, len(photos))
})
t.Run("latlng:0.00,-30.123.0,49.519234,9.1001234", func(t *testing.T) {
t.Run("latlng:0.00,-30.123,49.519234,9.1001234", func(t *testing.T) {
var f form.SearchPhotos
f.Query = "latlng:0.00,-30.123.0,49.519234,9.1001234"
f.Query = "latlng:0.00,-30.123,49.519234,9.1001234"
f.Count = 10
f.Offset = 0
f.Order = "imported"
@ -715,10 +715,10 @@ func TestPhotos(t *testing.T) {
}
for _, p := range photos {
assert.GreaterOrEqual(t, 49.519234, p.PhotoLat)
assert.LessOrEqual(t, 0.00, p.PhotoLat)
assert.GreaterOrEqual(t, 9.1001234, p.PhotoLng)
assert.LessOrEqual(t, -30.123, p.PhotoLng)
assert.GreaterOrEqual(t, 49.519234, p.PhotoLat)
assert.GreaterOrEqual(t, 9.1001234, p.PhotoLng)
}
assert.LessOrEqual(t, 10, len(photos))