2020-01-05 14:18:40 +01:00
|
|
|
package query
|
2018-09-12 16:37:30 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2018-10-31 07:14:33 +01:00
|
|
|
|
2019-12-11 14:10:20 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
2018-09-12 16:37:30 +02:00
|
|
|
)
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
func TestPhotoByID(t *testing.T) {
|
2020-02-02 13:03:08 +01:00
|
|
|
t.Run("photo found", func(t *testing.T) {
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := PhotoByID(1000000)
|
2020-05-13 11:57:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-02-02 13:03:08 +01:00
|
|
|
assert.Equal(t, 2790, result.PhotoYear)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("no photo found", func(t *testing.T) {
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := PhotoByID(99999)
|
2020-02-02 13:03:08 +01:00
|
|
|
assert.Error(t, err, "record not found")
|
|
|
|
t.Log(result)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
func TestPhotoByUUID(t *testing.T) {
|
2020-02-02 13:03:08 +01:00
|
|
|
t.Run("photo found", func(t *testing.T) {
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := PhotoByUUID("pt9jtdre2lvl0y12")
|
2020-05-13 11:57:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-02-02 13:03:08 +01:00
|
|
|
assert.Equal(t, "Reunion", result.PhotoTitle)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("no photo found", func(t *testing.T) {
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := PhotoByUUID("99999")
|
2020-02-02 13:03:08 +01:00
|
|
|
assert.Error(t, err, "record not found")
|
|
|
|
t.Log(result)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
func TestPreloadPhotoByUUID(t *testing.T) {
|
2020-02-02 13:03:08 +01:00
|
|
|
t.Run("photo found", func(t *testing.T) {
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := PreloadPhotoByUUID("pt9jtdre2lvl0y12")
|
2020-05-13 11:57:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-02-02 13:03:08 +01:00
|
|
|
assert.Equal(t, "Reunion", result.PhotoTitle)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("no photo found", func(t *testing.T) {
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := PreloadPhotoByUUID("99999")
|
2020-02-02 13:03:08 +01:00
|
|
|
assert.Error(t, err, "record not found")
|
|
|
|
t.Log(result)
|
|
|
|
})
|
|
|
|
}
|
2020-05-13 11:57:54 +02:00
|
|
|
|
|
|
|
func TestMissingPhotos(t *testing.T) {
|
|
|
|
r, err := MissingPhotos(15, 0)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(r))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestResetPhotosQuality(t *testing.T) {
|
|
|
|
err := ResetPhotosQuality()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|