2020-07-14 17:02:39 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
2020-11-21 18:08:41 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-07-14 17:02:39 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetShares(t *testing.T) {
|
2022-10-13 22:11:02 +02:00
|
|
|
t.Run("InvalidToken", func(t *testing.T) {
|
2020-07-14 17:02:39 +02:00
|
|
|
app, router, _ := NewApiTest()
|
|
|
|
Shares(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/1jxf3jfn2k/st9lxuqxpogaaba7")
|
|
|
|
assert.Equal(t, http.StatusTemporaryRedirect, r.Code)
|
|
|
|
})
|
|
|
|
//TODO Why does it panic?
|
|
|
|
/*t.Run("valid token and share", func(t *testing.T) {
|
|
|
|
app, router, _ := NewApiTest()
|
|
|
|
Shares(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/4jxf3jfn2k/at9lxuqxpogaaba7")
|
|
|
|
assert.Equal(t, http.StatusTemporaryRedirect, r.Code)
|
|
|
|
})*/
|
2022-10-13 22:11:02 +02:00
|
|
|
t.Run("InvalidToken", func(t *testing.T) {
|
2020-07-14 17:02:39 +02:00
|
|
|
app, router, _ := NewApiTest()
|
|
|
|
Shares(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/xxx")
|
|
|
|
assert.Equal(t, http.StatusTemporaryRedirect, r.Code)
|
|
|
|
})
|
|
|
|
//TODO Why does it panic?
|
|
|
|
/*t.Run("valid token", func(t *testing.T) {
|
|
|
|
app, router, _ := NewApiTest()
|
|
|
|
Shares(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/4jxf3jfn2k")
|
|
|
|
assert.Equal(t, http.StatusTemporaryRedirect, r.Code)
|
|
|
|
})*/
|
|
|
|
}
|