refac: migration crash, real-database tests, site deleted during create, ruels out of the repo, lists
This commit is contained in:
1 parent
680b9a1308
commit
9d284e65a9
62 files changed
+1858
-987
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"RenewCMS/api/pkg/apperr"
|
||||
"RenewCMS/internal/domain/audit"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestArticleCreateSiteDeletedHTTP(t *testing.T) {
|
||||
t.Run("A site deleted between its lookup and the insert answers 409 target_site_deleted", func(t *testing.T) {
|
||||
w := newCreateSiteWorld(t)
|
||||
w.transactor.removed = map[uint32]bool{createSiteNotes: true}
|
||||
before := w.snapshot()
|
||||
|
||||
response := w.send(storyWriter, http.MethodPost, createSitePath, `{"title":"Plain","site":"notes"}`)
|
||||
|
||||
if response.Code != http.StatusConflict || strings.TrimSpace(response.text()) != apperr.TargetSiteDeletedErrorMessage {
|
||||
t.Fatalf("expected 409 %q, got %d %q", apperr.TargetSiteDeletedErrorMessage, response.Code, response.text())
|
||||
}
|
||||
w.expectUnchanged(before)
|
||||
events := w.eventsOf(audit.ActionArticleCreate)
|
||||
if len(events) != 1 || events[0].Outcome != audit.OutcomeFailed || events[0].FailureReason == nil || *events[0].FailureReason != "The site was deleted while the article was being created." {
|
||||
t.Errorf("one failed article.create event with a plain reason expected: %+v", events)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user