Подключите RabbitMQ и отдельный обработчик заданий

This commit is contained in:
2026-11-18 15:33:33 +03:00
parent 752f29573b
commit 2dc566e6ec
19 changed files with 818 additions and 14 deletions
+37
View File
@@ -0,0 +1,37 @@
package processing
import (
"context"
"crypto/sha256"
"errors"
"io"
"strings"
"testing"
"messenger/internal/attachment"
"messenger/internal/pipeline"
)
type stagedSource struct {
attachment.Blobs
body string
}
func (s stagedSource) Open(context.Context, string) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader(s.body)), nil
}
func TestReadOriginalValidatesPersistedSizeAndDigest(t *testing.T) {
h := sha256.Sum256([]byte("accepted"))
c := &pipeline.Claim{SizeBytes: 8, Hash: h[:], SourceKey: "staging/test"}
for _, bad := range []string{"truncated", "altered!", "oversized bytes"} {
_, err := readOriginal(t.Context(), stagedSource{body: bad}, c)
if !errors.Is(err, errSourceMismatch) {
t.Fatalf("body %q: %v", bad, err)
}
}
got, err := readOriginal(t.Context(), stagedSource{body: "accepted"}, c)
if err != nil || string(got) != "accepted" {
t.Fatalf("valid original: %v", err)
}
}