photoprism/internal/query/albums_test.go

96 lines
1.9 KiB
Go
Raw Normal View History

2020-01-27 17:00:36 +01:00
package query
import (
"testing"
"github.com/stretchr/testify/assert"
2020-01-27 17:00:36 +01:00
)
func TestAlbumByUID(t *testing.T) {
t.Run("existing uid", func(t *testing.T) {
album, err := AlbumByUID("at9lxuqxpogaaba7")
if err != nil {
t.Fatal(err)
}
2021-07-22 13:53:17 +02:00
assert.Equal(t, "Christmas 2030", album.AlbumTitle)
2020-01-27 17:00:36 +01:00
})
t.Run("not existing uid", func(t *testing.T) {
album, err := AlbumByUID("3765")
2020-01-27 17:00:36 +01:00
assert.Error(t, err, "record not found")
t.Log(album)
2020-01-27 17:00:36 +01:00
})
}
func TestAlbumCoverByUID(t *testing.T) {
t.Run("existing uid default album", func(t *testing.T) {
file, err := AlbumCoverByUID("at9lxuqxpogaaba8")
if err != nil {
t.Fatal(err)
}
2021-08-05 12:33:52 +02:00
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", file.FileName)
2020-01-27 17:00:36 +01:00
})
t.Run("existing uid folder album", func(t *testing.T) {
file, err := AlbumCoverByUID("at1lxuqipogaaba1")
if err != nil {
t.Fatal(err)
}
2021-08-16 17:15:06 +02:00
assert.Equal(t, "1990/04/bridge2.jpg", file.FileName)
})
t.Run("existing uid empty moment album", func(t *testing.T) {
file, err := AlbumCoverByUID("at7axuzitogaaiax")
2021-09-06 11:22:44 +02:00
assert.EqualError(t, err, "no cover found", err)
assert.Equal(t, "", file.FileName)
})
t.Run("not existing uid", func(t *testing.T) {
file, err := AlbumCoverByUID("3765")
2020-01-27 17:00:36 +01:00
assert.Error(t, err, "record not found")
t.Log(file)
})
}
func TestUpdateAlbumDates(t *testing.T) {
t.Run("success", func(t *testing.T) {
if err := UpdateAlbumDates(); err != nil {
t.Fatal(err)
}
})
}
func TestUpdateMissingAlbumEntries(t *testing.T) {
t.Run("success", func(t *testing.T) {
if err := UpdateMissingAlbumEntries(); err != nil {
t.Fatal(err)
}
})
}
func TestAlbumEntryFound(t *testing.T) {
t.Run("success", func(t *testing.T) {
if err := AlbumEntryFound("pt9jtxrexxvl0yh0"); err != nil {
t.Fatal(err)
}
})
}
2021-03-03 11:49:32 +01:00
func TestGetAlbums(t *testing.T) {
t.Run("success", func(t *testing.T) {
r, err := Albums(0, 3)
2021-03-03 11:49:32 +01:00
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 3, len(r))
})
}