photoprism/internal/api/import_test.go

31 lines
718 B
Go
Raw Normal View History

2020-05-14 16:10:01 +00:00
package api
import (
"encoding/json"
2020-05-14 16:10:01 +00:00
"net/http"
"testing"
"github.com/photoprism/photoprism/internal/i18n"
"github.com/stretchr/testify/assert"
)
2020-05-14 16:10:01 +00:00
func TestCancelImport(t *testing.T) {
t.Run("successful request", func(t *testing.T) {
app, router, _ := NewApiTest()
CancelImport(router)
2020-05-14 16:10:01 +00:00
r := PerformRequest(app, "DELETE", "/api/v1/import")
var resp i18n.Response
if err := json.Unmarshal(r.Body.Bytes(), &resp); err != nil {
t.Fatal(err)
}
assert.True(t, resp.Success())
assert.Equal(t, i18n.Msg(i18n.MsgImportCanceled), resp.Msg)
assert.Equal(t, i18n.Msg(i18n.MsgImportCanceled), resp.String())
2020-05-14 16:10:01 +00:00
assert.Equal(t, http.StatusOK, r.Code)
assert.Equal(t, http.StatusOK, resp.Code)
2020-05-14 16:10:01 +00:00
})
}