2020-01-27 17:00:36 +01:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-01-27 17:00:36 +01:00
|
|
|
)
|
|
|
|
|
2020-05-23 20:58:58 +02:00
|
|
|
func TestAlbumByUID(t *testing.T) {
|
|
|
|
t.Run("existing uid", func(t *testing.T) {
|
2022-08-01 15:57:19 +02:00
|
|
|
if album, err := AlbumByUID("at9lxuqxpogaaba7"); err != nil {
|
2020-04-09 19:39:09 +02:00
|
|
|
t.Fatal(err)
|
2022-08-01 15:57:19 +02:00
|
|
|
} else {
|
|
|
|
assert.Equal(t, "Christmas 2030", album.AlbumTitle)
|
2020-04-09 19:39:09 +02:00
|
|
|
}
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
if cached, err := AlbumByUID("at9lxuqxpogaaba7"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
assert.Equal(t, "Christmas 2030", cached.AlbumTitle)
|
|
|
|
}
|
2020-01-27 17:00:36 +01:00
|
|
|
})
|
|
|
|
|
2020-05-23 20:58:58 +02:00
|
|
|
t.Run("not existing uid", func(t *testing.T) {
|
|
|
|
album, err := AlbumByUID("3765")
|
2022-08-01 15:57:19 +02:00
|
|
|
assert.NotNil(t, album)
|
2020-01-27 17:00:36 +01:00
|
|
|
assert.Error(t, err, "record not found")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-07-13 11:11:52 +02:00
|
|
|
func TestAlbumCoverByUID(t *testing.T) {
|
|
|
|
t.Run("existing uid default album", func(t *testing.T) {
|
2022-08-31 17:42:57 +02:00
|
|
|
file, err := AlbumCoverByUID("at9lxuqxpogaaba8", true)
|
2020-04-09 19:39:09 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-03-24 18:30:59 +01:00
|
|
|
assert.Equal(t, "1990/04/bridge2.jpg", file.FileName)
|
2020-01-27 17:00:36 +01:00
|
|
|
})
|
|
|
|
|
2020-07-13 11:11:52 +02:00
|
|
|
t.Run("existing uid folder album", func(t *testing.T) {
|
2022-08-31 17:42:57 +02:00
|
|
|
file, err := AlbumCoverByUID("at1lxuqipogaaba1", true)
|
2020-07-13 11:11:52 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-08-16 17:15:06 +02:00
|
|
|
assert.Equal(t, "1990/04/bridge2.jpg", file.FileName)
|
2020-07-13 11:11:52 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("existing uid empty moment album", func(t *testing.T) {
|
2022-08-31 17:42:57 +02:00
|
|
|
file, err := AlbumCoverByUID("at7axuzitogaaiax", true)
|
2020-07-13 11:11:52 +02:00
|
|
|
|
2021-09-06 11:22:44 +02:00
|
|
|
assert.EqualError(t, err, "no cover found", err)
|
2020-07-13 11:11:52 +02:00
|
|
|
assert.Equal(t, "", file.FileName)
|
|
|
|
})
|
|
|
|
|
2020-05-23 20:58:58 +02:00
|
|
|
t.Run("not existing uid", func(t *testing.T) {
|
2022-08-31 17:42:57 +02:00
|
|
|
file, err := AlbumCoverByUID("3765", true)
|
2020-01-27 17:00:36 +01:00
|
|
|
assert.Error(t, err, "record not found")
|
|
|
|
t.Log(file)
|
|
|
|
})
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
t.Run("existing uid empty month album", func(t *testing.T) {
|
2022-08-31 17:42:57 +02:00
|
|
|
file, err := AlbumCoverByUID("at1lxuqipogaabj9", true)
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
assert.EqualError(t, err, "no cover found", err)
|
|
|
|
assert.Equal(t, "", file.FileName)
|
|
|
|
})
|
2020-01-27 17:00:36 +01:00
|
|
|
}
|
|
|
|
|
2020-12-09 21:44:39 +01:00
|
|
|
func TestUpdateAlbumDates(t *testing.T) {
|
|
|
|
t.Run("success", func(t *testing.T) {
|
|
|
|
if err := UpdateAlbumDates(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
})
|
2020-12-09 21:49:41 +01:00
|
|
|
}
|
2020-12-27 13:11:08 +01:00
|
|
|
|
|
|
|
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) {
|
2021-09-18 15:32:39 +02:00
|
|
|
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))
|
|
|
|
})
|
|
|
|
}
|