package query import ( "github.com/stretchr/testify/assert" "testing" "time" ) func TestPhotosResults_Merged(t *testing.T) { result1 := PhotosResult{ ID: 111111, CreatedAt: time.Time{}, UpdatedAt: time.Time{}, DeletedAt: time.Time{}, TakenAt: time.Time{}, TakenAtLocal: time.Time{}, TakenSrc: "", TimeZone: "", PhotoUUID: "", 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: "", LocationID: "", PlaceID: "", LocLabel: "", LocCity: "", LocState: "", LocCountry: "", FileID: 0, FileUUID: "", FilePrimary: false, FileMissing: false, FileName: "", FileHash: "", FileType: "", FileMime: "", FileWidth: 0, FileHeight: 0, FileOrientation: 0, FileAspectRatio: 0, FileColors: "", FileChroma: 0, FileLuminance: "", FileDiff: 0, Files: nil, } result2 := PhotosResult{ ID: 22222, CreatedAt: time.Time{}, UpdatedAt: time.Time{}, DeletedAt: time.Time{}, TakenAt: time.Time{}, TakenAtLocal: time.Time{}, TakenSrc: "", TimeZone: "", PhotoUUID: "", 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: "", LocationID: "", PlaceID: "", LocLabel: "", LocCity: "", LocState: "", LocCountry: "", FileID: 0, FileUUID: "", FilePrimary: false, FileMissing: false, FileName: "", FileHash: "", FileType: "", FileMime: "", FileWidth: 0, FileHeight: 0, FileOrientation: 0, FileAspectRatio: 0, FileColors: "", FileChroma: 0, FileLuminance: "", FileDiff: 0, Files: nil, } results := PhotosResults{result1, result2} merged, int, err := results.Merged() if err != nil { t.Fatal(err) } assert.Equal(t, 2, int) t.Log(merged) } func TestPhotosResult_ShareFileName(t *testing.T) { t.Run("with photo title", func(t *testing.T) { result1 := PhotosResult{ 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: "", PhotoUUID: "uuid123", 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: "", LocationID: "", PlaceID: "", LocLabel: "", LocCity: "", LocState: "", LocCountry: "", FileID: 0, FileUUID: "", 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) { result1 := PhotosResult{ 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: "", PhotoUUID: "uuid123", 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: "", LocationID: "", PlaceID: "", LocLabel: "", LocCity: "", LocState: "", LocCountry: "", FileID: 0, FileUUID: "", 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, "20151111-090718-uuid123") }) }