2020-05-06 17:05:06 +02:00
|
|
|
package form
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
2020-11-21 18:08:41 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-05-06 17:05:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewPhoto(t *testing.T) {
|
|
|
|
t.Run("success", func(t *testing.T) {
|
2020-05-25 19:10:44 +02:00
|
|
|
photo := Photo{
|
2020-05-26 09:02:19 +02:00
|
|
|
TakenAt: time.Date(2008, 1, 1, 2, 0, 0, 0, time.UTC),
|
|
|
|
TakenAtLocal: time.Date(2008, 1, 1, 2, 0, 0, 0, time.UTC),
|
|
|
|
TakenSrc: "meta",
|
|
|
|
TimeZone: "UTC",
|
|
|
|
PhotoTitle: "Black beach",
|
|
|
|
TitleSrc: "manual",
|
|
|
|
PhotoFavorite: false,
|
|
|
|
PhotoPrivate: false,
|
|
|
|
PhotoType: "image",
|
2020-12-19 19:15:32 +01:00
|
|
|
PhotoStack: int8(1),
|
2020-05-26 09:02:19 +02:00
|
|
|
PhotoLat: 9.9999,
|
|
|
|
PhotoLng: 8.8888,
|
|
|
|
PhotoAltitude: 2,
|
|
|
|
PhotoIso: 5,
|
2020-05-25 19:10:44 +02:00
|
|
|
PhotoFocalLength: 10,
|
2020-05-26 09:02:19 +02:00
|
|
|
PhotoFNumber: 3.3,
|
|
|
|
PhotoExposure: "exposure",
|
|
|
|
CameraID: uint(3),
|
|
|
|
CameraSrc: "meta",
|
|
|
|
LensID: uint(6),
|
2020-07-12 08:27:05 +02:00
|
|
|
CellID: "1234",
|
|
|
|
PlaceSrc: "geo",
|
2020-05-29 12:56:24 +02:00
|
|
|
PlaceID: "765",
|
2020-05-26 09:02:19 +02:00
|
|
|
PhotoCountry: "de"}
|
2020-05-06 17:05:06 +02:00
|
|
|
|
|
|
|
r, err := NewPhoto(photo)
|
|
|
|
|
|
|
|
if err != nil {
|
2020-05-08 19:34:29 +02:00
|
|
|
t.Fatal(err)
|
2020-05-06 17:05:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, time.Date(2008, 1, 1, 2, 0, 0, 0, time.UTC), r.TakenAt)
|
|
|
|
assert.Equal(t, time.Date(2008, 1, 1, 2, 0, 0, 0, time.UTC), r.TakenAtLocal)
|
2020-05-25 19:10:44 +02:00
|
|
|
assert.Equal(t, "meta", r.TakenSrc)
|
2020-05-06 17:05:06 +02:00
|
|
|
assert.Equal(t, "UTC", r.TimeZone)
|
|
|
|
assert.Equal(t, "Black beach", r.PhotoTitle)
|
|
|
|
assert.Equal(t, "manual", r.TitleSrc)
|
|
|
|
assert.Equal(t, false, r.PhotoFavorite)
|
|
|
|
assert.Equal(t, false, r.PhotoPrivate)
|
2020-05-21 13:26:28 +02:00
|
|
|
assert.Equal(t, "image", r.PhotoType)
|
2020-12-19 19:15:32 +01:00
|
|
|
assert.Equal(t, int8(1), r.PhotoStack)
|
2020-05-06 17:05:06 +02:00
|
|
|
assert.Equal(t, float32(9.9999), r.PhotoLat)
|
|
|
|
assert.Equal(t, float32(8.8888), r.PhotoLng)
|
|
|
|
assert.Equal(t, 2, r.PhotoAltitude)
|
|
|
|
assert.Equal(t, 5, r.PhotoIso)
|
|
|
|
assert.Equal(t, 10, r.PhotoFocalLength)
|
|
|
|
assert.Equal(t, float32(3.3), r.PhotoFNumber)
|
|
|
|
assert.Equal(t, "exposure", r.PhotoExposure)
|
|
|
|
assert.Equal(t, uint(3), r.CameraID)
|
2020-05-25 19:10:44 +02:00
|
|
|
assert.Equal(t, "meta", r.CameraSrc)
|
2020-05-06 17:05:06 +02:00
|
|
|
assert.Equal(t, uint(6), r.LensID)
|
2020-07-12 08:27:05 +02:00
|
|
|
assert.Equal(t, "1234", r.CellID)
|
|
|
|
assert.Equal(t, "geo", r.PlaceSrc)
|
2020-05-29 12:56:24 +02:00
|
|
|
assert.Equal(t, "765", r.PlaceID)
|
2020-05-06 17:05:06 +02:00
|
|
|
assert.Equal(t, "de", r.PhotoCountry)
|
|
|
|
})
|
|
|
|
}
|