Files
archie/internal/app/archied/telegram_session_store_test.go
T
sam 5fa010c9c2 fix(plugin): add missing CLAUDE.md reference to plugin engine rule
Test TestPluginEngineRuleIsCanonicalAndSharedByAgentInstructions was
missing entirely, letting CLAUDE.md drift out of sync with
ARCHITECTURE.md#plugin-engine-rule-strict. Added the test and the
missing reference.
2026-08-31 21:25:20 +10:00

42 lines
1.1 KiB
Go

package archied
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)
}
}