photoprism/internal/api/services_upload_test.go
Michael Mayer e3bb8b19dd Routing: Prefix frontend UI routes with /library #840 #2466
Also improves migrations and updates the db schema docs.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-15 21:54:11 +02:00

30 lines
885 B
Go

package api
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tidwall/gjson"
"github.com/photoprism/photoprism/internal/i18n"
)
func TestUploadToService(t *testing.T) {
t.Run("invalid request", func(t *testing.T) {
app, router, _ := NewApiTest()
UploadToService(router)
r := PerformRequest(app, "POST", "/api/v1/services/1000000/upload")
val := gjson.Get(r.Body.String(), "error")
assert.Equal(t, i18n.Msg(i18n.ErrBadRequest), val.String())
assert.Equal(t, http.StatusBadRequest, r.Code)
})
t.Run("account not found", func(t *testing.T) {
app, router, _ := NewApiTest()
UploadToService(router)
r := PerformRequest(app, "POST", "/api/v1/services/999000/upload")
val := gjson.Get(r.Body.String(), "error")
assert.Equal(t, i18n.Msg(i18n.ErrAccountNotFound), val.String())
assert.Equal(t, http.StatusNotFound, r.Code)
})
}