Files
archie/cmd/archie-state-store/import_test.go
T
sam ae552db7e0 refactor(store)!: remove the SQLite task store, the PocketBase event store and the SQLite session store
The State Store, event capture and Gateway conversations already serve from
PostgreSQL. This deletes internal/store and internal/infrastructure/edastore,
the SQLite gateway session store and openProductionTaskStore, and the -db
recovery path on a legacy task file; backup, restore, validate and rollback
work on the database database_url names.

- The binding-secret cipher moves to internal/infrastructure/bindingcipher and
  ToolCall to internal/infrastructure/postgres.
- NewSessionStoreMemory is now a pure in-memory store that passes the shared
  SessionStore conformance suite.
- Tests run against PostgreSQL through internal/infrastructure/postgres/pgstore;
  legacyimport/legacyfixture writes the legacy files the import and the boot
  gate read.
- The cron dialect is owned in internal/domain/scheduling, so
  github.com/pocketbase/pocketbase and pocketbase/dbx leave go.mod.
  modernc.org/sqlite stays for the one-time import (legacyread).
- The UI and Messaging architecture gates ban the Postgres and legacy readers
  in place of internal/store.
2026-09-24 14:43:50 +10:00

47 lines
1.6 KiB
Go

package main
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/samcharles93/archie-core/internal/infrastructure/legacyimport/legacyfixture"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgtest"
)
func TestMain(m *testing.M) { os.Exit(pgtest.Main(m)) }
// TestRecoveryImportMovesTheInstallOnce drives the import the way an operator
// does: the configured db_path locates every legacy file, and a second run
// against the same database is refused because the first one completed.
func TestRecoveryImportMovesTheInstallOnce(t *testing.T) {
dbPath := filepath.Join(t.TempDir(), "archie.db")
legacyfixture.Install(t, dbPath)
url := pgtest.URL(t)
code, stdout, stderr := runRecoveryCmd(t, "import", "-db-path", dbPath, "-database-url", url)
if code != 0 {
t.Fatalf("import exited %d; stderr = %q", code, stderr)
}
if !strings.Contains(stdout, "tasks=2") {
t.Errorf("import summary %q does not report the imported task", stdout)
}
pool, err := postgres.Open(t.Context(), url)
if err != nil {
t.Fatalf("postgres.Open: %v", err)
}
defer pool.Close()
var issue int64
if err := pool.QueryRow(t.Context(), "SELECT issue_number FROM tasks WHERE id = 1").Scan(&issue); err != nil || issue != 7 {
t.Fatalf("imported task 1 issue = %d, %v; want 7", issue, err)
}
code, _, stderr = runRecoveryCmd(t, "import", "-db-path", dbPath, "-database-url", url)
if code != 1 || !strings.Contains(stderr, "already holds a completed import") {
t.Fatalf("second import exited %d, stderr %q; want 1 naming the completed import", code, stderr)
}
}