Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package campaigns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
func TestResolveAudienceSeededWooDemo(t *testing.T) {
|
||||
dsn := os.Getenv("DATABASE_URL")
|
||||
if dsn == "" {
|
||||
t.Skip("DATABASE_URL not set")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
pg, err := pgxpool.New(ctx, dsn)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer pg.Close()
|
||||
|
||||
var companyID uuid.UUID
|
||||
var af []byte
|
||||
err = pg.QueryRow(ctx, `
|
||||
SELECT company_id, audience_filter
|
||||
FROM email_campaigns
|
||||
WHERE name LIKE 'Woo demo%'
|
||||
ORDER BY updated_at DESC LIMIT 1`).Scan(&companyID, &af)
|
||||
if err != nil {
|
||||
t.Skip("no seeded woo demo campaign:", err)
|
||||
}
|
||||
var m map[string]any
|
||||
if err := json.Unmarshal(af, &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
svc := &Service{Pool: pg}
|
||||
res, err := svc.ResolveAudienceMap(ctx, companyID, m, 100)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.Total < 3 {
|
||||
t.Fatalf("expected >=3 audience customers, got %d (%v)", res.Total, res.Customers)
|
||||
}
|
||||
t.Logf("resolved %d customers via campaign filter: %+v", res.Total, res.Customers)
|
||||
}
|
||||
Reference in New Issue
Block a user