photoprism/internal/api/photo_thumbnail_test.go
2020-02-03 15:50:25 +01:00

32 lines
848 B
Go

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)
})
t.Run("could not find original", func(t *testing.T) {
app, router, ctx := NewApiTest()
GetThumbnail(router, ctx)
result := PerformRequest(app, "GET", "/api/v1/thumbnails/123xxx/tile_500")
assert.Equal(t, http.StatusNotFound, result.Code)
})
}