Files
archie/internal/app/archied/chat_store_composition_test.go
T
sam c1cd5c8f5b chore(state-store): remove the one-time SQLite import and db_path
Every install serves from Postgres, so the legacyread/legacyimport packages,
the archie-state-store import command, the boot gate that refused to serve
over unimported SQLite files, and db_path (which only located those files)
go. Migration 0010 drops the import_completion table.
2026-09-25 00:40:48 +10:00

43 lines
1.4 KiB
Go

package archied
import (
"log/slog"
"testing"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/gateway"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgstore"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgtest"
)
func TestRemoteChatCompositionPreservesChannelTurnLedger(t *testing.T) {
cfg := config.Config{
DatabaseURL: pgtest.URL(t),
Services: config.Services{config.ServiceNameGateway: {Target: "127.0.0.1:1"}},
}
st := pgstore.Open(t)
t.Cleanup(func() { _ = st.Close() })
b := &boot{cfg: cfg, log: slog.Default(), cfgHolder: config.NewHolder(cfg), stateStore: st, personas: gateway.NewPersonaRegistry(gateway.DefaultPersonas())}
t.Cleanup(b.cleanup)
if err := b.openStores(t.Context()); err != nil {
t.Fatal(err)
}
if b.chatSessionStore == nil {
t.Fatal("startup did not open the channel conversation store")
}
sessions := b.chatSessionStore
if err := b.setupLLMAndChat(t.Context()); err != nil {
t.Fatal(err)
}
if b.chatSessionStore != sessions {
t.Fatal("remote web chat replaced the channel conversation store")
}
ledger, ok := b.chatSessionStore.(gateway.TurnLedger)
if !ok {
t.Fatal("channel conversation store does not implement TurnLedger")
}
if err := ledger.RecoverTurns(t.Context(), "test-owner"); err != nil {
t.Fatal(err)
}
}