Test: Add test for api/album

This commit is contained in:
Theresa Gresch 2020-02-02 18:41:03 +01:00
parent 14f7702d4f
commit c647908d3d
2 changed files with 28 additions and 2 deletions

View file

@ -10,6 +10,7 @@ INSERT INTO albums (id, album_uuid, album_name, album_slug, album_favorite) VALU
INSERT INTO albums (id, album_uuid, cover_uuid, album_name, album_slug, album_favorite) VALUES ('1', '4', '654', 'Holiday2030', 'holiday-2030', 1);
INSERT INTO albums (id, album_uuid, cover_uuid, album_name, album_slug, album_favorite) VALUES ('3', '5', '654', 'Berlin2019', 'berlin-2019', 0);
INSERT INTO photos_albums (album_uuid, photo_uuid) VALUES ('4', '654');
INSERT INTO photos_albums (album_uuid, photo_uuid) VALUES ('5', '658');
INSERT INTO files (id, photo_id, photo_uuid, file_name, file_primary, file_hash, file_missing) VALUES ('1', '1', '654', 'exampleFileName.jpg', 1, '123xxx', 0);
INSERT INTO files (id, photo_id, photo_uuid, file_name, file_primary, file_hash, file_missing) VALUES ('2', '2', '655', 'exampleDNGFile.dng', 1, '124xxx', 0);
INSERT INTO files (id, photo_id, photo_uuid, file_name, file_primary, file_hash, file_missing) VALUES ('3', '2', '655', 'exampleXmpFile.xmp', 0, '125xxx', 0);

View file

@ -82,7 +82,7 @@ func TestDislikeAlbum(t *testing.T) {
t.Run("dislike not existing album", func(t *testing.T) {
app, router, conf := NewApiTest()
LikeAlbum(router, conf)
DislikeAlbum(router, conf)
result := PerformRequest(app, "DELETE", "/api/v1/albums/5678/like")
assert.Equal(t, http.StatusNotFound, result.Code)
@ -90,14 +90,39 @@ func TestDislikeAlbum(t *testing.T) {
t.Run("dislike existing album", func(t *testing.T) {
app, router, conf := NewApiTest()
LikeAlbum(router, conf)
DislikeAlbum(router, conf)
result := PerformRequest(app, "DELETE", "/api/v1/albums/4/like")
assert.Equal(t, http.StatusOK, result.Code)
})
}
func TestDownloadAlbum(t *testing.T) {
t.Run("download not existing album", func(t *testing.T) {
app, router, conf := NewApiTest()
DownloadAlbum(router, conf)
result := PerformRequest(app, "GET", "/api/v1/albums/5678/download")
assert.Equal(t, http.StatusNotFound, result.Code)
})
t.Run("download existing album", func(t *testing.T) {
app, router, conf := NewApiTest()
DownloadAlbum(router, conf)
result := PerformRequest(app, "GET", "/api/v1/albums/4/download")
assert.Equal(t, http.StatusOK, result.Code)
})
}
func TestAlbumThumbnail(t *testing.T) {
t.Run("could not find original", func(t *testing.T) {
app, router, ctx := NewApiTest()
AlbumThumbnail(router, ctx)
result := PerformRequest(app, "GET", "/api/v1/albums/4/thumbnail/tile_500")
assert.Equal(t, http.StatusNotFound, result.Code)
})
t.Run("invalid type", func(t *testing.T) {
app, router, ctx := NewApiTest()
AlbumThumbnail(router, ctx)