Files
archie/cmd/archied/telegram_session_store_test.go
T
sam 61b4b7b0cf refactor(store): replace legacy persistence with SQLite
Task and event persistence now uses a dedicated SQLite sidecar derived from the configured state prefix, matching the independently persisted conversation store. The configured path now means a state-path prefix rather than a database file so fresh SQLite state never attempts to interpret the previous storage format.

Remove the retired implementation and dependency completely, strengthen SQLite migrations and concurrency behavior, restore backend-neutral coverage, and align configuration, operational guidance, UI labels, and deployment documentation with the new storage and host-daemon topology.
2026-08-09 22:27:25 +10:00

42 lines
1.1 KiB
Go

package main
import (
"bytes"
"fmt"
"os"
"path/filepath"
"testing"
"github.com/samcharles93/archie-core/internal/config"
)
func TestTelegramConversationStoreUsesFreshSQLiteWithoutReadingTaskLog(t *testing.T) {
taskLogPath := filepath.Join(t.TempDir(), "tasks.db")
taskLog := []byte("not a SQLite database")
if err := os.WriteFile(taskLogPath, taskLog, 0o600); err != nil {
t.Fatalf("write task log fixture: %v", err)
}
sessions, err := makeTelegramSessionStore(config.Config{
DBPath: taskLogPath,
})
if err != nil {
t.Fatalf("makeTelegramSessionStore: %v", err)
}
t.Cleanup(func() { _ = sessions.Close() })
if got, want := fmt.Sprintf("%T", sessions), "*gateway.sqliteSessionStore"; got != want {
t.Fatalf("conversation store type = %q, want %q", got, want)
}
if _, err := os.Stat(conversationDBPath(taskLogPath)); err != nil {
t.Fatalf("stat conversation database: %v", err)
}
gotTaskLog, err := os.ReadFile(taskLogPath)
if err != nil {
t.Fatalf("read task log fixture: %v", err)
}
if !bytes.Equal(gotTaskLog, taskLog) {
t.Fatalf("task log changed during conversation-store cutover: got %q, want %q", gotTaskLog, taskLog)
}
}