Logs: Improve event log and messages in i18n package

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer
2020-07-07 10:51:55 +02:00
parent e743ae4480
commit d1db3d04f7
51 changed files with 896 additions and 389 deletions

View File

@@ -1,11 +1,12 @@
package api
import (
"encoding/json"
"net/http"
"testing"
"github.com/photoprism/photoprism/internal/i18n"
"github.com/stretchr/testify/assert"
"github.com/tidwall/gjson"
)
func TestCancelImport(t *testing.T) {
@@ -13,8 +14,17 @@ func TestCancelImport(t *testing.T) {
app, router, _ := NewApiTest()
CancelImport(router)
r := PerformRequest(app, "DELETE", "/api/v1/import")
val := gjson.Get(r.Body.String(), "message")
assert.Equal(t, "import canceled", val.String())
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())
assert.Equal(t, http.StatusOK, r.Code)
assert.Equal(t, http.StatusOK, resp.Code)
})
}