Files
photoprism/internal/api/index_test.go
2025-01-17 02:55:07 +01:00

32 lines
707 B
Go

package api
import (
"encoding/json"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/photoprism/photoprism/pkg/i18n"
)
func TestCancelIndex(t *testing.T) {
t.Run("Success", func(t *testing.T) {
app, router, _ := NewApiTest()
CancelIndexing(router)
r := PerformRequest(app, "DELETE", "/api/v1/index")
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.MsgIndexingCanceled), resp.Msg)
assert.Equal(t, i18n.Msg(i18n.MsgIndexingCanceled), resp.String())
assert.Equal(t, http.StatusOK, r.Code)
assert.Equal(t, http.StatusOK, resp.Code)
})
}