2020-05-06 12:56:13 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
2020-11-21 18:08:41 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-05-06 12:56:13 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetSvg(t *testing.T) {
|
|
|
|
t.Run("photo", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/photo")
|
|
|
|
assert.Equal(t, photoIconSvg, r.Body.Bytes())
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
2020-07-14 17:02:39 +02:00
|
|
|
t.Run("raw", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/raw")
|
|
|
|
assert.Equal(t, rawIconSvg, r.Body.Bytes())
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
|
|
|
t.Run("file", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/file")
|
|
|
|
assert.Equal(t, fileIconSvg, r.Body.Bytes())
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
|
|
|
t.Run("video", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/video")
|
|
|
|
assert.Equal(t, videoIconSvg, r.Body.Bytes())
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
2020-05-06 12:56:13 +02:00
|
|
|
t.Run("label", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/label")
|
|
|
|
assert.Equal(t, labelIconSvg, r.Body.Bytes())
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
|
|
|
t.Run("album", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/album")
|
|
|
|
assert.Equal(t, albumIconSvg, r.Body.Bytes())
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
2020-07-14 17:02:39 +02:00
|
|
|
t.Run("folder", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/folder")
|
2020-12-30 18:12:30 +01:00
|
|
|
assert.Equal(t, folderIconSvg, r.Body.Bytes())
|
2020-07-14 17:02:39 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
2020-05-06 12:56:13 +02:00
|
|
|
t.Run("broken", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/broken")
|
|
|
|
assert.Equal(t, brokenIconSvg, r.Body.Bytes())
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
|
|
|
t.Run("uncached", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
t.Log(conf)
|
|
|
|
GetSvg(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/svg/uncached")
|
|
|
|
assert.Equal(t, uncachedIconSvg, r.Body.Bytes())
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
|
|
|
}
|