2020-05-14 18:10:01 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetVideo(t *testing.T) {
|
|
|
|
t.Run("invalid hash", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
2020-06-25 14:54:04 +02:00
|
|
|
GetVideo(router)
|
2020-05-27 19:56:56 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/videos/xxx/"+conf.PreviewToken()+"/mp4")
|
2020-05-14 18:10:01 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
2020-06-25 14:54:04 +02:00
|
|
|
|
2020-05-14 18:10:01 +02:00
|
|
|
t.Run("invalid type", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
2020-06-25 14:54:04 +02:00
|
|
|
GetVideo(router)
|
2020-05-27 19:56:56 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/videos/acad9168fa6acc5c5c2965ddf6ec465ca42fd831/"+conf.PreviewToken()+"/xxx")
|
2020-05-14 18:10:01 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
2020-06-25 14:54:04 +02:00
|
|
|
|
2020-05-14 18:10:01 +02:00
|
|
|
t.Run("file for video not found", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
2020-06-25 14:54:04 +02:00
|
|
|
GetVideo(router)
|
2020-05-27 19:56:56 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/videos/acad9168fa6acc5c5c2965ddf6ec465ca42fd831/"+conf.PreviewToken()+"/mp4")
|
2020-05-14 18:10:01 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
2020-06-25 14:54:04 +02:00
|
|
|
|
2020-05-14 18:10:01 +02:00
|
|
|
t.Run("file with error", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
2020-06-25 14:54:04 +02:00
|
|
|
GetVideo(router)
|
2020-05-27 19:56:56 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/videos/acad9168fa6acc5c5c2965ddf6ec465ca42fd832/"+conf.PreviewToken()+"/mp4")
|
2020-05-14 18:10:01 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
|
|
|
}
|