mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Backend: Refactor API source structure
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetThumbnail(t *testing.T) {
|
||||
t.Run("invalid type", func(t *testing.T) {
|
||||
app, router, ctx := NewApiTest()
|
||||
GetThumbnail(router, ctx)
|
||||
result := PerformRequest(app, "GET", "/api/v1/thumbnails/1/xxx")
|
||||
|
||||
assert.Equal(t, http.StatusBadRequest, result.Code)
|
||||
})
|
||||
t.Run("invalid hash", func(t *testing.T) {
|
||||
app, router, ctx := NewApiTest()
|
||||
GetThumbnail(router, ctx)
|
||||
result := PerformRequest(app, "GET", "/api/v1/thumbnails/1/tile_500")
|
||||
|
||||
assert.Equal(t, http.StatusNotFound, result.Code)
|
||||
})
|
||||
}
|
||||
|
||||
func TestLabelThumbnail(t *testing.T) {
|
||||
t.Run("invalid type", func(t *testing.T) {
|
||||
app, router, ctx := NewApiTest()
|
||||
LabelThumbnail(router, ctx)
|
||||
result := PerformRequest(app, "GET", "/api/v1/labels/dog/thumbnail/xxx")
|
||||
|
||||
assert.Equal(t, http.StatusBadRequest, result.Code)
|
||||
})
|
||||
t.Run("invalid label", func(t *testing.T) {
|
||||
app, router, ctx := NewApiTest()
|
||||
LabelThumbnail(router, ctx)
|
||||
result := PerformRequest(app, "GET", "/api/v1/labels/xxx/thumbnail/tile_500")
|
||||
|
||||
assert.Equal(t, http.StatusNotFound, result.Code)
|
||||
})
|
||||
}
|
||||
|
||||
func TestAlbumThumbnail(t *testing.T) {
|
||||
t.Run("invalid type", func(t *testing.T) {
|
||||
app, router, ctx := NewApiTest()
|
||||
AlbumThumbnail(router, ctx)
|
||||
result := PerformRequest(app, "GET", "/api/v1/albums/1/thumbnail/xxx")
|
||||
|
||||
assert.Equal(t, http.StatusBadRequest, result.Code)
|
||||
})
|
||||
t.Run("album has no photo (because is not existing)", func(t *testing.T) {
|
||||
app, router, ctx := NewApiTest()
|
||||
AlbumThumbnail(router, ctx)
|
||||
result := PerformRequest(app, "GET", "/api/v1/albums/987-986435/thumbnail/tile_500")
|
||||
|
||||
assert.Equal(t, http.StatusOK, result.Code)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user