2020-05-13 17:23:16 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPhotosResults_Merged(t *testing.T) {
|
2020-05-25 19:10:44 +02:00
|
|
|
result1 := PhotoResult{
|
2020-05-13 17:23:16 +02:00
|
|
|
ID: 111111,
|
|
|
|
CreatedAt: time.Time{},
|
|
|
|
UpdatedAt: time.Time{},
|
|
|
|
DeletedAt: time.Time{},
|
|
|
|
TakenAt: time.Time{},
|
|
|
|
TakenAtLocal: time.Time{},
|
|
|
|
TakenSrc: "",
|
|
|
|
TimeZone: "",
|
2020-05-23 20:58:58 +02:00
|
|
|
PhotoUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
PhotoPath: "",
|
|
|
|
PhotoName: "",
|
|
|
|
PhotoTitle: "Photo1",
|
|
|
|
PhotoYear: 0,
|
|
|
|
PhotoMonth: 0,
|
|
|
|
PhotoCountry: "",
|
|
|
|
PhotoFavorite: false,
|
|
|
|
PhotoPrivate: false,
|
|
|
|
PhotoLat: 0,
|
|
|
|
PhotoLng: 0,
|
|
|
|
PhotoAltitude: 0,
|
|
|
|
PhotoIso: 0,
|
|
|
|
PhotoFocalLength: 0,
|
|
|
|
PhotoFNumber: 0,
|
|
|
|
PhotoExposure: "",
|
|
|
|
PhotoQuality: 0,
|
|
|
|
PhotoResolution: 0,
|
|
|
|
Merged: false,
|
|
|
|
CameraID: 0,
|
|
|
|
CameraModel: "",
|
|
|
|
CameraMake: "",
|
|
|
|
LensID: 0,
|
|
|
|
LensModel: "",
|
|
|
|
LensMake: "",
|
2020-05-25 19:10:44 +02:00
|
|
|
LocUID: "",
|
|
|
|
PlaceUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
LocLabel: "",
|
|
|
|
LocCity: "",
|
|
|
|
LocState: "",
|
|
|
|
LocCountry: "",
|
|
|
|
FileID: 0,
|
2020-05-23 20:58:58 +02:00
|
|
|
FileUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
FilePrimary: false,
|
|
|
|
FileMissing: false,
|
|
|
|
FileName: "",
|
|
|
|
FileHash: "",
|
|
|
|
FileType: "",
|
|
|
|
FileMime: "",
|
|
|
|
FileWidth: 0,
|
|
|
|
FileHeight: 0,
|
|
|
|
FileOrientation: 0,
|
|
|
|
FileAspectRatio: 0,
|
|
|
|
FileColors: "",
|
|
|
|
FileChroma: 0,
|
|
|
|
FileLuminance: "",
|
|
|
|
FileDiff: 0,
|
|
|
|
Files: nil,
|
|
|
|
}
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
result2 := PhotoResult{
|
2020-05-13 17:23:16 +02:00
|
|
|
ID: 22222,
|
|
|
|
CreatedAt: time.Time{},
|
|
|
|
UpdatedAt: time.Time{},
|
|
|
|
DeletedAt: time.Time{},
|
|
|
|
TakenAt: time.Time{},
|
|
|
|
TakenAtLocal: time.Time{},
|
|
|
|
TakenSrc: "",
|
|
|
|
TimeZone: "",
|
2020-05-23 20:58:58 +02:00
|
|
|
PhotoUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
PhotoPath: "",
|
|
|
|
PhotoName: "",
|
|
|
|
PhotoTitle: "Photo2",
|
|
|
|
PhotoYear: 0,
|
|
|
|
PhotoMonth: 0,
|
|
|
|
PhotoCountry: "",
|
|
|
|
PhotoFavorite: false,
|
|
|
|
PhotoPrivate: false,
|
|
|
|
PhotoLat: 0,
|
|
|
|
PhotoLng: 0,
|
|
|
|
PhotoAltitude: 0,
|
|
|
|
PhotoIso: 0,
|
|
|
|
PhotoFocalLength: 0,
|
|
|
|
PhotoFNumber: 0,
|
|
|
|
PhotoExposure: "",
|
|
|
|
PhotoQuality: 0,
|
|
|
|
PhotoResolution: 0,
|
|
|
|
Merged: false,
|
|
|
|
CameraID: 0,
|
|
|
|
CameraModel: "",
|
|
|
|
CameraMake: "",
|
|
|
|
LensID: 0,
|
|
|
|
LensModel: "",
|
|
|
|
LensMake: "",
|
2020-05-25 19:10:44 +02:00
|
|
|
LocUID: "",
|
|
|
|
PlaceUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
LocLabel: "",
|
|
|
|
LocCity: "",
|
|
|
|
LocState: "",
|
|
|
|
LocCountry: "",
|
|
|
|
FileID: 0,
|
2020-05-23 20:58:58 +02:00
|
|
|
FileUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
FilePrimary: false,
|
|
|
|
FileMissing: false,
|
|
|
|
FileName: "",
|
|
|
|
FileHash: "",
|
|
|
|
FileType: "",
|
|
|
|
FileMime: "",
|
|
|
|
FileWidth: 0,
|
|
|
|
FileHeight: 0,
|
|
|
|
FileOrientation: 0,
|
|
|
|
FileAspectRatio: 0,
|
|
|
|
FileColors: "",
|
|
|
|
FileChroma: 0,
|
|
|
|
FileLuminance: "",
|
|
|
|
FileDiff: 0,
|
|
|
|
Files: nil,
|
|
|
|
}
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
results := PhotoResults{result1, result2}
|
2020-05-13 17:23:16 +02:00
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
merged, count, err := results.Merged()
|
2020-05-13 17:23:16 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-05-25 19:10:44 +02:00
|
|
|
assert.Equal(t, 2, count)
|
2020-05-13 17:23:16 +02:00
|
|
|
t.Log(merged)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPhotosResult_ShareFileName(t *testing.T) {
|
|
|
|
t.Run("with photo title", func(t *testing.T) {
|
2020-05-25 19:10:44 +02:00
|
|
|
result1 := PhotoResult{
|
2020-05-13 17:23:16 +02:00
|
|
|
ID: 111111,
|
|
|
|
CreatedAt: time.Time{},
|
|
|
|
UpdatedAt: time.Time{},
|
|
|
|
DeletedAt: time.Time{},
|
|
|
|
TakenAt: time.Date(2015, 11, 11, 9, 7, 18, 0, time.UTC),
|
|
|
|
TakenAtLocal: time.Date(2013, 11, 11, 9, 7, 18, 0, time.UTC),
|
|
|
|
TakenSrc: "",
|
|
|
|
TimeZone: "",
|
2020-05-23 20:58:58 +02:00
|
|
|
PhotoUID: "uid123",
|
2020-05-13 17:23:16 +02:00
|
|
|
PhotoPath: "",
|
|
|
|
PhotoName: "",
|
|
|
|
PhotoTitle: "PhotoTitle123",
|
|
|
|
PhotoYear: 0,
|
|
|
|
PhotoMonth: 0,
|
|
|
|
PhotoCountry: "",
|
|
|
|
PhotoFavorite: false,
|
|
|
|
PhotoPrivate: false,
|
|
|
|
PhotoLat: 0,
|
|
|
|
PhotoLng: 0,
|
|
|
|
PhotoAltitude: 0,
|
|
|
|
PhotoIso: 0,
|
|
|
|
PhotoFocalLength: 0,
|
|
|
|
PhotoFNumber: 0,
|
|
|
|
PhotoExposure: "",
|
|
|
|
PhotoQuality: 0,
|
|
|
|
PhotoResolution: 0,
|
|
|
|
Merged: false,
|
|
|
|
CameraID: 0,
|
|
|
|
CameraModel: "",
|
|
|
|
CameraMake: "",
|
|
|
|
LensID: 0,
|
|
|
|
LensModel: "",
|
|
|
|
LensMake: "",
|
2020-05-25 19:10:44 +02:00
|
|
|
LocUID: "",
|
|
|
|
PlaceUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
LocLabel: "",
|
|
|
|
LocCity: "",
|
|
|
|
LocState: "",
|
|
|
|
LocCountry: "",
|
|
|
|
FileID: 0,
|
2020-05-23 20:58:58 +02:00
|
|
|
FileUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
FilePrimary: false,
|
|
|
|
FileMissing: false,
|
|
|
|
FileName: "",
|
|
|
|
FileHash: "",
|
|
|
|
FileType: "",
|
|
|
|
FileMime: "",
|
|
|
|
FileWidth: 0,
|
|
|
|
FileHeight: 0,
|
|
|
|
FileOrientation: 0,
|
|
|
|
FileAspectRatio: 0,
|
|
|
|
FileColors: "",
|
|
|
|
FileChroma: 0,
|
|
|
|
FileLuminance: "",
|
|
|
|
FileDiff: 0,
|
|
|
|
Files: nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
r := result1.ShareFileName()
|
|
|
|
assert.Contains(t, r, "20131111-090718-Phototitle123")
|
|
|
|
})
|
|
|
|
t.Run("without photo title", func(t *testing.T) {
|
2020-05-25 19:10:44 +02:00
|
|
|
result1 := PhotoResult{
|
2020-05-13 17:23:16 +02:00
|
|
|
ID: 111111,
|
|
|
|
CreatedAt: time.Time{},
|
|
|
|
UpdatedAt: time.Time{},
|
|
|
|
DeletedAt: time.Time{},
|
|
|
|
TakenAt: time.Date(2013, 11, 11, 9, 7, 18, 0, time.UTC),
|
|
|
|
TakenAtLocal: time.Date(2015, 11, 11, 9, 7, 18, 0, time.UTC),
|
|
|
|
TakenSrc: "",
|
|
|
|
TimeZone: "",
|
2020-05-23 20:58:58 +02:00
|
|
|
PhotoUID: "uid123",
|
2020-05-13 17:23:16 +02:00
|
|
|
PhotoPath: "",
|
|
|
|
PhotoName: "",
|
|
|
|
PhotoTitle: "",
|
|
|
|
PhotoYear: 0,
|
|
|
|
PhotoMonth: 0,
|
|
|
|
PhotoCountry: "",
|
|
|
|
PhotoFavorite: false,
|
|
|
|
PhotoPrivate: false,
|
|
|
|
PhotoLat: 0,
|
|
|
|
PhotoLng: 0,
|
|
|
|
PhotoAltitude: 0,
|
|
|
|
PhotoIso: 0,
|
|
|
|
PhotoFocalLength: 0,
|
|
|
|
PhotoFNumber: 0,
|
|
|
|
PhotoExposure: "",
|
|
|
|
PhotoQuality: 0,
|
|
|
|
PhotoResolution: 0,
|
|
|
|
Merged: false,
|
|
|
|
CameraID: 0,
|
|
|
|
CameraModel: "",
|
|
|
|
CameraMake: "",
|
|
|
|
LensID: 0,
|
|
|
|
LensModel: "",
|
|
|
|
LensMake: "",
|
2020-05-25 19:10:44 +02:00
|
|
|
LocUID: "",
|
|
|
|
PlaceUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
LocLabel: "",
|
|
|
|
LocCity: "",
|
|
|
|
LocState: "",
|
|
|
|
LocCountry: "",
|
|
|
|
FileID: 0,
|
2020-05-23 20:58:58 +02:00
|
|
|
FileUID: "",
|
2020-05-13 17:23:16 +02:00
|
|
|
FilePrimary: false,
|
|
|
|
FileMissing: false,
|
|
|
|
FileName: "",
|
|
|
|
FileHash: "",
|
|
|
|
FileType: "",
|
|
|
|
FileMime: "",
|
|
|
|
FileWidth: 0,
|
|
|
|
FileHeight: 0,
|
|
|
|
FileOrientation: 0,
|
|
|
|
FileAspectRatio: 0,
|
|
|
|
FileColors: "",
|
|
|
|
FileChroma: 0,
|
|
|
|
FileLuminance: "",
|
|
|
|
FileDiff: 0,
|
|
|
|
Files: nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
r := result1.ShareFileName()
|
2020-05-23 20:58:58 +02:00
|
|
|
assert.Contains(t, r, "20151111-090718-uid123")
|
2020-05-13 17:23:16 +02:00
|
|
|
})
|
|
|
|
}
|