2d73a3d1db
* fix: keep completed office comments editable Keep the office task detail composer editable after completed sessions load, including projectless office tasks. Update verification tests for SHA-pinned GitHub actions. Extract the dockview main area to satisfy the existing max-lines lint rule. * fix: preserve upload artifact version guard * fix: clarify upload artifact pin check * fix: wake completed office sessions on comments * fix: queue completed office comment runs * fix: preserve dispatcher session lookup errors * fix: resolve office comment wake review issues * fix: stabilize comment wake idempotency * fix: salt custom comment wake keys * fix: address comment wake review cleanup * fix: avoid comment payload allocation overflow pattern * fix: salt comment wake action variants * fix: resolve cross-task primary by target step * fix: resolve cross-task participant roles * fix: surface cross-task comment run status * fix: use target steps for cross-task queue runs * fix: avoid comment run lookup scan regression * fix: cover cross-task queue run edge cases * fix: index comment payload run lookup * fix: support postgres comment run index * fix: tighten queue run target test coverage * fix: route source comment run updates * fix: preserve cross-task comment wakes * fix: tighten comment wake identity * fix: align comment wake routing * fix: remove stale primary resolver * fix: dedupe comment run status * fix: tighten legacy comment wake dedupe * fix: remove unreachable comment wake guard * fix: skip duplicate comment reactivity wakes * fix: route comment wakes synchronously * fix: share comment engine dispatch contracts * fix: preserve comment wake fallbacks * fix: preserve done comment runner * fix: guard empty task runner fallback * fix: handle empty task runner fallback * fix: stabilize completed comment wakes * fix: index comment runner fallback --------- Co-authored-by: root <root@kandev.ts.net>
114 lines
2.8 KiB
Go
114 lines
2.8 KiB
Go
package sqlite_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
_ "github.com/mattn/go-sqlite3"
|
|
|
|
settingsstore "github.com/kandev/kandev/internal/agent/settings/store"
|
|
"github.com/kandev/kandev/internal/office/repository/sqlite"
|
|
)
|
|
|
|
// newTestRepo creates an in-memory SQLite repo for testing.
|
|
//
|
|
// Office agent CRUD now reads/writes the unified agent_profiles table
|
|
// (ADR 0005 Wave C), so tests must also bring up the settings store
|
|
// schema. Both stores share the same writer/reader connections.
|
|
func newTestRepo(t *testing.T) *sqlite.Repository {
|
|
t.Helper()
|
|
db, err := sqlx.Open("sqlite3", ":memory:")
|
|
if err != nil {
|
|
t.Fatalf("open sqlite: %v", err)
|
|
}
|
|
t.Cleanup(func() { _ = db.Close() })
|
|
|
|
if _, _, err := settingsstore.Provide(db, db, nil); err != nil {
|
|
t.Fatalf("settings store init: %v", err)
|
|
}
|
|
|
|
repo, err := sqlite.NewWithDB(db, db, nil)
|
|
if err != nil {
|
|
t.Fatalf("new repo: %v", err)
|
|
}
|
|
return repo
|
|
}
|
|
|
|
func TestInitSchema_AllTablesExist(t *testing.T) {
|
|
db, err := sqlx.Open("sqlite3", ":memory:")
|
|
if err != nil {
|
|
t.Fatalf("open sqlite: %v", err)
|
|
}
|
|
defer func() { _ = db.Close() }()
|
|
|
|
_, err = sqlite.NewWithDB(db, db, nil)
|
|
if err != nil {
|
|
t.Fatalf("new repo: %v", err)
|
|
}
|
|
|
|
expectedTables := []string{
|
|
"office_agent_runtime",
|
|
"office_cost_events",
|
|
"office_budget_policies",
|
|
"runs",
|
|
"office_routines",
|
|
"office_routine_triggers",
|
|
"office_routine_runs",
|
|
"office_approvals",
|
|
"office_activity_log",
|
|
"office_agent_memory",
|
|
"office_channels",
|
|
"task_blockers",
|
|
"task_comments",
|
|
"office_onboarding",
|
|
"office_agent_instructions",
|
|
"office_labels",
|
|
"office_task_labels",
|
|
"task_workspace_groups",
|
|
"task_workspace_group_members",
|
|
}
|
|
|
|
for _, table := range expectedTables {
|
|
var count int
|
|
err := db.QueryRow(
|
|
`SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name=?`, table,
|
|
).Scan(&count)
|
|
if err != nil {
|
|
t.Errorf("query table %s: %v", table, err)
|
|
continue
|
|
}
|
|
if count != 1 {
|
|
t.Errorf("table %s not found (count=%d)", table, count)
|
|
}
|
|
}
|
|
|
|
var indexCount int
|
|
err = db.QueryRow(
|
|
`SELECT COUNT(*) FROM sqlite_master WHERE type='index' AND name='idx_run_payload_comment_id'`,
|
|
).Scan(&indexCount)
|
|
if err != nil {
|
|
t.Fatalf("query idx_run_payload_comment_id: %v", err)
|
|
}
|
|
if indexCount != 1 {
|
|
t.Fatalf("idx_run_payload_comment_id not found (count=%d)", indexCount)
|
|
}
|
|
}
|
|
|
|
func TestInitSchema_Idempotent(t *testing.T) {
|
|
db, err := sqlx.Open("sqlite3", ":memory:")
|
|
if err != nil {
|
|
t.Fatalf("open sqlite: %v", err)
|
|
}
|
|
defer func() { _ = db.Close() }()
|
|
|
|
// Create repo twice - should not error on second call
|
|
_, err = sqlite.NewWithDB(db, db, nil)
|
|
if err != nil {
|
|
t.Fatalf("first init: %v", err)
|
|
}
|
|
_, err = sqlite.NewWithDB(db, db, nil)
|
|
if err != nil {
|
|
t.Fatalf("second init should be idempotent: %v", err)
|
|
}
|
|
}
|