photoprism/internal/query/photo_test.go
Michael Mayer 03ec4b586d Initial commit for folders and moments #154 #260 #331
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-05-23 20:58:58 +02:00

71 lines
1.4 KiB
Go

package query
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPhotoByID(t *testing.T) {
t.Run("photo found", func(t *testing.T) {
result, err := PhotoByID(1000000)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 2790, result.PhotoYear)
})
t.Run("no photo found", func(t *testing.T) {
result, err := PhotoByID(99999)
assert.Error(t, err, "record not found")
t.Log(result)
})
}
func TestPhotoByUID(t *testing.T) {
t.Run("photo found", func(t *testing.T) {
result, err := PhotoByUID("pt9jtdre2lvl0y12")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "Reunion", result.PhotoTitle)
})
t.Run("no photo found", func(t *testing.T) {
result, err := PhotoByUID("99999")
assert.Error(t, err, "record not found")
t.Log(result)
})
}
func TestPreloadPhotoByUID(t *testing.T) {
t.Run("photo found", func(t *testing.T) {
result, err := PreloadPhotoByUID("pt9jtdre2lvl0y12")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "Reunion", result.PhotoTitle)
})
t.Run("no photo found", func(t *testing.T) {
result, err := PreloadPhotoByUID("99999")
assert.Error(t, err, "record not found")
t.Log(result)
})
}
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)
}
}