lab4 done
This commit is contained in:
@@ -7,6 +7,7 @@ type Message struct {
|
||||
ID string
|
||||
ChatID string
|
||||
SenderID string
|
||||
AttachmentIDs []string
|
||||
Text string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
package postgres_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/png"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitflic.ru/akselbant/mtusi2026lab1-fork/internal/attachment"
|
||||
"gitflic.ru/akselbant/mtusi2026lab1-fork/internal/pkg/domain"
|
||||
"gitflic.ru/akselbant/mtusi2026lab1-fork/internal/pkg/repository/postgres"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
)
|
||||
|
||||
type fakeObject struct {
|
||||
data []byte
|
||||
modified time.Time
|
||||
}
|
||||
type fakeS3 struct {
|
||||
mu sync.Mutex
|
||||
objects map[string]fakeObject
|
||||
failPUT bool
|
||||
}
|
||||
|
||||
func (f *fakeS3) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
key := strings.TrimPrefix(r.URL.Path, "/attachments/")
|
||||
if r.Method == "GET" && r.URL.Path == "/attachments/" || r.Method == "GET" && r.URL.Path == "/attachments" {
|
||||
type item struct {
|
||||
Key string
|
||||
LastModified string
|
||||
ETag string
|
||||
Size int
|
||||
}
|
||||
type listing struct {
|
||||
XMLName xml.Name `xml:"ListBucketResult"`
|
||||
Xmlns string `xml:"xmlns,attr"`
|
||||
Name string
|
||||
Prefix string
|
||||
MaxKeys int
|
||||
IsTruncated bool
|
||||
Contents []item
|
||||
}
|
||||
l := listing{Xmlns: "http://s3.amazonaws.com/doc/2006-03-01/", Name: "attachments", Prefix: r.URL.Query().Get("prefix"), MaxKeys: 1000}
|
||||
for k, v := range f.objects {
|
||||
if strings.HasPrefix(k, l.Prefix) {
|
||||
l.Contents = append(l.Contents, item{Key: k, LastModified: v.modified.UTC().Format("2006-01-02T15:04:05.000Z"), ETag: `"abc"`, Size: len(v.data)})
|
||||
}
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/xml")
|
||||
xml.NewEncoder(w).Encode(l)
|
||||
return
|
||||
}
|
||||
if r.Method == "PUT" {
|
||||
if f.failPUT {
|
||||
w.WriteHeader(503)
|
||||
fmt.Fprint(w, `<Error><Code>ServiceUnavailable</Code></Error>`)
|
||||
return
|
||||
}
|
||||
var data []byte
|
||||
var err error
|
||||
if strings.Contains(r.Header.Get("Content-Encoding"), "aws-chunked") || strings.HasPrefix(r.Header.Get("X-Amz-Content-Sha256"), "STREAMING-") {
|
||||
reader := bufio.NewReader(r.Body)
|
||||
for {
|
||||
line, e := reader.ReadString('\n')
|
||||
if e != nil {
|
||||
err = e
|
||||
break
|
||||
}
|
||||
size, e := strconv.ParseInt(strings.Split(strings.TrimSpace(line), ";")[0], 16, 64)
|
||||
if e != nil {
|
||||
err = e
|
||||
break
|
||||
}
|
||||
if size == 0 {
|
||||
break
|
||||
}
|
||||
chunk := make([]byte, size)
|
||||
if _, e = io.ReadFull(reader, chunk); e != nil {
|
||||
err = e
|
||||
break
|
||||
}
|
||||
data = append(data, chunk...)
|
||||
if _, e = reader.Discard(2); e != nil {
|
||||
err = e
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data, err = io.ReadAll(r.Body)
|
||||
}
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
return
|
||||
}
|
||||
f.objects[key] = fakeObject{data: data, modified: time.Now().UTC()}
|
||||
w.Header().Set("ETag", `"900150983cd24fb0d6963f7d28e17f72"`)
|
||||
w.WriteHeader(200)
|
||||
return
|
||||
}
|
||||
obj, ok := f.objects[key]
|
||||
if !ok {
|
||||
w.WriteHeader(404)
|
||||
if r.Method != "HEAD" {
|
||||
fmt.Fprint(w, `<Error><Code>NoSuchKey</Code></Error>`)
|
||||
}
|
||||
return
|
||||
}
|
||||
if r.Method == "DELETE" {
|
||||
delete(f.objects, key)
|
||||
w.WriteHeader(204)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Last-Modified", obj.modified.UTC().Format(http.TimeFormat))
|
||||
w.Header().Set("ETag", `"abc"`)
|
||||
w.Header().Set("Content-Length", fmt.Sprint(len(obj.data)))
|
||||
w.Header().Set("Content-Type", "image/png")
|
||||
if r.Method == "GET" {
|
||||
w.Write(obj.data)
|
||||
}
|
||||
}
|
||||
func lab4Backend(t *testing.T, pool *pgxpool.Pool, repo *postgres.Storage, user domain.User, chat domain.Chat) {
|
||||
ctx := context.Background()
|
||||
fake := &fakeS3{objects: map[string]fakeObject{}}
|
||||
server := httptest.NewServer(fake)
|
||||
defer server.Close()
|
||||
client, err := minio.New(strings.TrimPrefix(server.URL, "http://"), &minio.Options{Creds: credentials.NewStaticV4("test-key", "test-secret", ""), Region: "us-east-1", MaxRetries: 1})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
service := attachment.New(pool, &attachment.Store{Client: client, Bucket: "attachments"})
|
||||
var imageBytes bytes.Buffer
|
||||
if err = png.Encode(&imageBytes, image.NewRGBA(image.Rect(0, 0, 10, 8))); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
upload := func(name string) attachment.Attachment {
|
||||
t.Helper()
|
||||
a, e := service.Upload(ctx, chat.ID, user.ID, name, "image/png", bytes.NewReader(imageBytes.Bytes()))
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
return a
|
||||
}
|
||||
first := upload("first.png")
|
||||
second := upload("second.png")
|
||||
requireCode := func(err error, want domain.ErrorCode) {
|
||||
t.Helper()
|
||||
e, ok := domain.AsApplicationError(err)
|
||||
if !ok || e.Code != want {
|
||||
t.Fatalf("expected %s, got %v", want, err)
|
||||
}
|
||||
}
|
||||
outside, err := repo.CreateUser(ctx, "attachment_outsider", "Outside", "hash")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = service.Get(ctx, first.ID, outside.ID)
|
||||
requireCode(err, domain.ErrorNotFound)
|
||||
obj, err := service.Content(ctx, first)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, err := io.ReadAll(obj)
|
||||
obj.Close()
|
||||
if err != nil || !bytes.Equal(data, imageBytes.Bytes()) {
|
||||
t.Fatalf("original mismatch: %v", err)
|
||||
}
|
||||
otherChat, err := repo.CreateChat(ctx, "Other", []string{user.ID})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = repo.CreateMessageWithAttachments(ctx, otherChat.ID, user.ID, "", "cross-chat", []string{first.ID})
|
||||
requireCode(err, domain.ErrorNotFound)
|
||||
_, err = repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "", "unknown", []string{uuid.NewString()})
|
||||
requireCode(err, domain.ErrorNotFound)
|
||||
sent, err := repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "", "ordered", []string{first.ID, second.ID})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
replay, err := repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "", "ordered", []string{first.ID, second.ID})
|
||||
if err != nil || sent.ID != replay.ID {
|
||||
t.Fatalf("replay failed: %v", err)
|
||||
}
|
||||
_, err = repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "", "ordered", []string{second.ID, first.ID})
|
||||
requireCode(err, domain.ErrorConflict)
|
||||
textOnly, err := repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "text", "empty-equivalent", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
replay, err = repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "text", "empty-equivalent", []string{})
|
||||
if err != nil || textOnly.ID != replay.ID {
|
||||
t.Fatalf("absent/empty differs: %v", err)
|
||||
}
|
||||
|
||||
const callers = 12
|
||||
outcomes := make(chan domain.Message, callers)
|
||||
failures := make(chan error, callers)
|
||||
var concurrent sync.WaitGroup
|
||||
start := make(chan struct{})
|
||||
for i := 0; i < callers; i++ {
|
||||
concurrent.Add(1)
|
||||
go func() {
|
||||
defer concurrent.Done()
|
||||
<-start
|
||||
m, e := repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "", "concurrent-attachments", []string{first.ID, second.ID})
|
||||
if e != nil {
|
||||
failures <- e
|
||||
} else {
|
||||
outcomes <- m
|
||||
}
|
||||
}()
|
||||
}
|
||||
close(start)
|
||||
concurrent.Wait()
|
||||
close(outcomes)
|
||||
close(failures)
|
||||
for e := range failures {
|
||||
t.Fatal(e)
|
||||
}
|
||||
identity := ""
|
||||
for m := range outcomes {
|
||||
if identity == "" {
|
||||
identity = m.ID
|
||||
}
|
||||
if m.ID != identity {
|
||||
t.Fatal("duplicate concurrent attachment message")
|
||||
}
|
||||
}
|
||||
var effects int
|
||||
if err = pool.QueryRow(ctx, `SELECT count(*) FROM messages WHERE chat_id=$1 AND idempotency_key='concurrent-attachments'`, chat.ID).Scan(&effects); err != nil || effects != 1 {
|
||||
t.Fatalf("concurrent effects=%d %v", effects, err)
|
||||
}
|
||||
t.Log("ACL, original bytes, cross-chat attachment rejection, ordered/concurrent idempotency and absent=[] passed")
|
||||
|
||||
old := time.Now().Add(-3 * time.Minute)
|
||||
orphan := "original/" + uuid.NewString()
|
||||
fresh := "original/" + uuid.NewString()
|
||||
locked := "original/" + uuid.NewString()
|
||||
fake.mu.Lock()
|
||||
delete(fake.objects, first.Key)
|
||||
v := fake.objects[second.Key]
|
||||
v.modified = old
|
||||
fake.objects[second.Key] = v
|
||||
fake.objects[orphan] = fakeObject{data: []byte("orphan"), modified: old}
|
||||
fake.objects[fresh] = fakeObject{data: []byte("fresh"), modified: time.Now()}
|
||||
fake.objects[locked] = fakeObject{data: []byte("locked"), modified: old}
|
||||
fake.mu.Unlock()
|
||||
if _, err = pool.Exec(ctx, `UPDATE attachments SET created_at=$1 WHERE id=ANY($2::uuid[])`, old, []string{first.ID, second.ID}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hold, err := pool.Begin(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer hold.Rollback(ctx)
|
||||
if _, err = hold.Exec(ctx, `SELECT pg_advisory_xact_lock(hashtextextended($1,0))`, locked); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dry, err := service.Reconcile(ctx, false, 90*time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if dry.Orphans != 1 || dry.Missing != 1 || dry.ReferencedMissing != 1 || dry.LockedSkipped != 1 || dry.FreshSkipped < 1 || dry.Deleted != 0 || dry.MarkedFailed != 0 {
|
||||
t.Fatalf("bad dry-run %+v", dry)
|
||||
}
|
||||
var status string
|
||||
if err = pool.QueryRow(ctx, `SELECT status FROM attachments WHERE id=$1`, first.ID).Scan(&status); err != nil || status != "ready" {
|
||||
t.Fatalf("dry-run mutated metadata %s %v", status, err)
|
||||
}
|
||||
applied, err := service.Reconcile(ctx, true, 90*time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if applied.Deleted != 1 || applied.MarkedFailed != 1 {
|
||||
t.Fatalf("bad apply %+v", applied)
|
||||
}
|
||||
fake.mu.Lock()
|
||||
_, hasOrphan := fake.objects[orphan]
|
||||
_, hasFresh := fake.objects[fresh]
|
||||
_, hasLinked := fake.objects[second.Key]
|
||||
_, hasLocked := fake.objects[locked]
|
||||
fake.mu.Unlock()
|
||||
if hasOrphan || !hasFresh || !hasLinked || !hasLocked {
|
||||
t.Fatal("unsafe object cleanup")
|
||||
}
|
||||
_, err = service.Get(ctx, first.ID, user.ID)
|
||||
requireCode(err, domain.ErrorConflict)
|
||||
_, err = repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "", "failed-attachment", []string{first.ID})
|
||||
requireCode(err, domain.ErrorConflict)
|
||||
replay, err = repo.CreateMessageWithAttachments(ctx, chat.ID, user.ID, "", "ordered", []string{first.ID, second.ID})
|
||||
if err != nil || replay.ID != sent.ID {
|
||||
t.Fatalf("historical replay changed after missing: %v", err)
|
||||
}
|
||||
repeated, err := service.Reconcile(ctx, true, 90*time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if repeated.Deleted != 0 || repeated.MarkedFailed != 0 || repeated.Orphans != 0 || repeated.Missing != 0 {
|
||||
t.Fatalf("not repeatable %+v", repeated)
|
||||
}
|
||||
t.Logf("dry-run=%+v apply=%+v repeat=%+v; fresh, locked and referenced objects retained", dry, applied, repeated)
|
||||
}
|
||||
|
||||
func TestS3WireFixture(t *testing.T) {
|
||||
fake := &fakeS3{objects: map[string]fakeObject{}}
|
||||
server := httptest.NewServer(fake)
|
||||
defer server.Close()
|
||||
client, err := minio.New(strings.TrimPrefix(server.URL, "http://"), &minio.Options{Creds: credentials.NewStaticV4("test-key", "test-secret", ""), Region: "us-east-1", MaxRetries: 1})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
payload := []byte("exact object bytes")
|
||||
_, err = client.PutObject(context.Background(), "attachments", "original/test", bytes.NewReader(payload), int64(len(payload)), minio.PutObjectOptions{ContentType: "image/png", DisableMultipart: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
obj, err := client.GetObject(context.Background(), "attachments", "original/test", minio.GetObjectOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer obj.Close()
|
||||
got, err := io.ReadAll(obj)
|
||||
if err != nil || !bytes.Equal(got, payload) {
|
||||
t.Fatalf("wire fixture did not store original: %q %v", got, err)
|
||||
}
|
||||
}
|
||||
@@ -3,41 +3,76 @@ package postgres
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gitflic.ru/akselbant/mtusi2026lab1-fork/internal/pkg/domain"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"gitflic.ru/akselbant/mtusi2026lab1-fork/internal/pkg/domain"
|
||||
"slices"
|
||||
)
|
||||
|
||||
func (s *Storage) CreateMessage(ctx context.Context, chatID, senderID, text, key string) (domain.Message, error) {
|
||||
return s.CreateMessageWithAttachments(ctx, chatID, senderID, text, key, nil)
|
||||
}
|
||||
|
||||
func (s *Storage) CreateMessageWithAttachments(ctx context.Context, chatID, senderID, text, key string, ids []string) (domain.Message, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, s.timeout)
|
||||
defer cancel()
|
||||
message := domain.Message{ID: uuid.NewString(), ChatID: chatID, SenderID: senderID, Text: text}
|
||||
if ids == nil {
|
||||
ids = []string{}
|
||||
}
|
||||
tx, err := s.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return domain.Message{}, dbError(err)
|
||||
}
|
||||
defer tx.Rollback(context.Background())
|
||||
// Serialize this idempotency scope before validating attachments. A replay remains a
|
||||
// replay even when reconciliation has since marked an original as missing.
|
||||
if key != "" {
|
||||
_, err = tx.Exec(ctx, `SELECT pg_advisory_xact_lock(hashtextextended($1,0))`, senderID+":"+chatID+":"+key)
|
||||
if err != nil {
|
||||
return domain.Message{}, dbError(err)
|
||||
}
|
||||
old := domain.Message{ChatID: chatID, SenderID: senderID}
|
||||
err = tx.QueryRow(ctx, `SELECT id::text,text,attachment_ids::text[],created_at FROM messages WHERE sender_id=$1 AND chat_id=$2 AND idempotency_key=$3`, senderID, chatID, key).Scan(&old.ID, &old.Text, &old.AttachmentIDs, &old.CreatedAt)
|
||||
if err == nil {
|
||||
if old.Text != text || !slices.Equal(old.AttachmentIDs, ids) {
|
||||
return domain.Message{}, domain.NewApplicationError(domain.ErrorConflict, "Idempotency-Key уже использован с другим телом")
|
||||
}
|
||||
return old, nil
|
||||
}
|
||||
if !errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.Message{}, dbError(err)
|
||||
}
|
||||
}
|
||||
// Lock each metadata row against reconciler updates until the link is committed.
|
||||
for _, id := range ids {
|
||||
var status string
|
||||
err = tx.QueryRow(ctx, `SELECT status FROM attachments WHERE id=$1 AND chat_id=$2 FOR SHARE`, id, chatID).Scan(&status)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.Message{}, domain.NewApplicationError(domain.ErrorNotFound, "Объект не найден")
|
||||
}
|
||||
if err != nil {
|
||||
return domain.Message{}, dbError(err)
|
||||
}
|
||||
if status != "ready" {
|
||||
return domain.Message{}, domain.NewApplicationError(domain.ErrorConflict, "Вложение не готово")
|
||||
}
|
||||
}
|
||||
m := domain.Message{ID: uuid.NewString(), ChatID: chatID, SenderID: senderID, Text: text, AttachmentIDs: ids}
|
||||
var storedKey *string
|
||||
if key != "" {
|
||||
storedKey = &key
|
||||
}
|
||||
// One row contains both the side effect and its durable replay result.
|
||||
err := s.pool.QueryRow(ctx, `INSERT INTO messages(id,chat_id,sender_id,text,idempotency_key)
|
||||
VALUES($1,$2,$3,$4,$5) ON CONFLICT (sender_id,chat_id,idempotency_key) DO NOTHING RETURNING created_at`,
|
||||
message.ID, chatID, senderID, text, storedKey).Scan(&message.CreatedAt)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
// A new READ COMMITTED statement sees the winner after the unique-index wait.
|
||||
err = s.pool.QueryRow(ctx, `SELECT id::text,text,created_at FROM messages
|
||||
WHERE sender_id=$1 AND chat_id=$2 AND idempotency_key=$3`, senderID, chatID, key).
|
||||
Scan(&message.ID, &message.Text, &message.CreatedAt)
|
||||
if err == nil && message.Text != text {
|
||||
return domain.Message{}, domain.NewApplicationError(domain.ErrorConflict, "Idempotency-Key уже использован с другим телом")
|
||||
}
|
||||
err = tx.QueryRow(ctx, `INSERT INTO messages(id,chat_id,sender_id,text,idempotency_key,attachment_ids) VALUES($1,$2,$3,$4,$5,$6) RETURNING created_at`, m.ID, chatID, senderID, text, storedKey, ids).Scan(&m.CreatedAt)
|
||||
if err != nil {
|
||||
return domain.Message{}, dbError(err)
|
||||
}
|
||||
return message, dbError(err)
|
||||
return m, dbError(tx.Commit(ctx))
|
||||
}
|
||||
|
||||
func (s *Storage) ListMessages(ctx context.Context, chatID string, after *domain.Position, limit int) ([]domain.Message, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, s.timeout)
|
||||
defer cancel()
|
||||
query := `SELECT m.id::text,m.chat_id::text,m.sender_id::text,m.text,m.created_at FROM messages m WHERE m.chat_id=$1`
|
||||
query := `SELECT m.id::text,m.chat_id::text,m.sender_id::text,m.text,m.attachment_ids::text[],m.created_at FROM messages m WHERE m.chat_id=$1`
|
||||
args := []any{chatID, limit}
|
||||
if after != nil {
|
||||
query += ` AND (m.created_at,m.id)>($3,$4)`
|
||||
@@ -49,13 +84,13 @@ func (s *Storage) ListMessages(ctx context.Context, chatID string, after *domain
|
||||
return nil, dbError(err)
|
||||
}
|
||||
defer rows.Close()
|
||||
messages := make([]domain.Message, 0)
|
||||
result := []domain.Message{}
|
||||
for rows.Next() {
|
||||
var m domain.Message
|
||||
if err = rows.Scan(&m.ID, &m.ChatID, &m.SenderID, &m.Text, &m.CreatedAt); err != nil {
|
||||
if err = rows.Scan(&m.ID, &m.ChatID, &m.SenderID, &m.Text, &m.AttachmentIDs, &m.CreatedAt); err != nil {
|
||||
return nil, dbError(err)
|
||||
}
|
||||
messages = append(messages, m)
|
||||
result = append(result, m)
|
||||
}
|
||||
return messages, dbError(rows.Err())
|
||||
return result, dbError(rows.Err())
|
||||
}
|
||||
|
||||
@@ -142,6 +142,13 @@ func TestIntegration(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Run("lab4_attachments_and_reconciliation", func(t *testing.T) {
|
||||
isolated, e := repo.CreateChat(ctx, "Lab4", []string{user.ID})
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
lab4Backend(t, pool, repo, user, isolated)
|
||||
})
|
||||
_, err = pool.Exec(ctx, `INSERT INTO messages(id,chat_id,sender_id,text,created_at)
|
||||
SELECT md5(i::text)::uuid,$1,$2,'synthetic message '||i,
|
||||
timestamptz '2026-01-01 00:00:00+00' + (i / 10) * interval '1 millisecond'
|
||||
|
||||
Reference in New Issue
Block a user