2019-12-16 11:04:49 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetThumbnail(t *testing.T) {
|
|
|
|
t.Run("invalid type", func(t *testing.T) {
|
2020-05-27 19:38:40 +02:00
|
|
|
app, router, conf := NewApiTest()
|
2020-06-25 14:54:04 +02:00
|
|
|
GetThumbnail(router)
|
2020-05-27 19:56:56 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/t/1/"+conf.PreviewToken()+"/xxx")
|
2019-12-16 11:04:49 +01:00
|
|
|
|
2020-05-06 12:56:13 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
2019-12-16 11:04:49 +01:00
|
|
|
})
|
|
|
|
t.Run("invalid hash", func(t *testing.T) {
|
2020-05-27 19:38:40 +02:00
|
|
|
app, router, conf := NewApiTest()
|
2020-06-25 14:54:04 +02:00
|
|
|
GetThumbnail(router)
|
2020-05-27 19:56:56 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/t/1/"+conf.PreviewToken()+"/tile_500")
|
2019-12-16 11:04:49 +01:00
|
|
|
|
2020-05-06 12:56:13 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
2020-02-03 15:50:25 +01:00
|
|
|
})
|
|
|
|
t.Run("could not find original", func(t *testing.T) {
|
2020-05-27 19:38:40 +02:00
|
|
|
app, router, conf := NewApiTest()
|
2020-06-25 14:54:04 +02:00
|
|
|
GetThumbnail(router)
|
2020-05-27 19:56:56 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/t/2cad9168fa6acc5c5c2965ddf6ec465ca42fd818/"+conf.PreviewToken()+"/tile_500")
|
2020-05-06 12:56:13 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
2019-12-16 11:04:49 +01:00
|
|
|
})
|
|
|
|
}
|