oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "amadan.net/rastrillo/rastrillo/db"
5 "context"
6 "gorm.io/gorm"
7 "io"
8 "log/slog"
9 "path/filepath"
10 "testing"
11 "time"
12)
13
14func TestConversationSubscriptionUsesReaderPool(t *testing.T) {
15 d, err := db.Open(filepath.Join(t.TempDir(), "read.db"), slog.New(slog.NewTextHandler(io.Discard, nil)))
16 if err != nil {
17 t.Fatal(err)
18 }
19 defer d.Close()
20 held, err := d.Writer().BeginTx(context.Background(), nil)
21 if err != nil {
22 t.Fatal(err)
23 }
24 defer held.Rollback()
25 ctx, cancel := context.WithTimeout(context.Background(), 250*time.Millisecond)
26 defer cancel()
27 err = NewStore(d).coordinatorApplication().Read(ctx, func(tx *gorm.DB) error { var one int; return tx.Raw("SELECT 1").Scan(&one).Error })
28 if err != nil {
29 t.Fatal("conversation subscription waited for writer pool", err)
30 }
31}
32