photoprism/internal/query/albums_test.go
Michael Mayer 9d110e8b80 Search: Improve album, albums, lens, and camera filters #1994 #2079
Camera and lens can now also be searched by name. Escaping and parsing
of albums has been improved so that albums whose names start with and/or
contain numbers will be found.
2022-03-24 18:30:59 +01:00

102 lines
2.1 KiB
Go

package query
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestAlbumByUID(t *testing.T) {
t.Run("existing uid", func(t *testing.T) {
album, err := AlbumByUID("at9lxuqxpogaaba7")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "Christmas 2030", album.AlbumTitle)
})
t.Run("not existing uid", func(t *testing.T) {
album, err := AlbumByUID("3765")
assert.Error(t, err, "record not found")
t.Log(album)
})
}
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)
}
assert.Equal(t, "1990/04/bridge2.jpg", file.FileName)
})
t.Run("existing uid folder album", func(t *testing.T) {
file, err := AlbumCoverByUID("at1lxuqipogaaba1")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "1990/04/bridge2.jpg", file.FileName)
})
t.Run("existing uid empty moment album", func(t *testing.T) {
file, err := AlbumCoverByUID("at7axuzitogaaiax")
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")
assert.Error(t, err, "record not found")
t.Log(file)
})
t.Run("existing uid empty month album", func(t *testing.T) {
file, err := AlbumCoverByUID("at1lxuqipogaabj9")
assert.EqualError(t, err, "no cover found", err)
assert.Equal(t, "", file.FileName)
})
}
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)
}
})
}
func TestGetAlbums(t *testing.T) {
t.Run("success", func(t *testing.T) {
r, err := Albums(0, 3)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 3, len(r))
})
}