photoprism/internal/api/photo_thumbnail_test.go
Michael Mayer 6f6e3799dc Refactor download urls and client config
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-05-27 19:38:40 +02:00

31 lines
876 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, conf := NewApiTest()
GetThumbnail(router, conf)
r := PerformRequest(app, "GET", "/api/v1/t/1/"+conf.ThumbToken()+"/xxx")
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("invalid hash", func(t *testing.T) {
app, router, conf := NewApiTest()
GetThumbnail(router, conf)
r := PerformRequest(app, "GET", "/api/v1/t/1/"+conf.ThumbToken()+"/tile_500")
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("could not find original", func(t *testing.T) {
app, router, conf := NewApiTest()
GetThumbnail(router, conf)
r := PerformRequest(app, "GET", "/api/v1/t/2cad9168fa6acc5c5c2965ddf6ec465ca42fd818/"+conf.ThumbToken()+"/tile_500")
assert.Equal(t, http.StatusOK, r.Code)
})
}