TestMigrationAddsAutoRunColumns verifies the autonomous-run bookkeeping columns land on the tasks table and round-trip through ScanTask.
(t *testing.T)
| 221 | // TestMigrationAddsAutoRunColumns verifies the autonomous-run bookkeeping |
| 222 | // columns land on the tasks table and round-trip through ScanTask. |
| 223 | func TestMigrationAddsAutoRunColumns(t *testing.T) { |
| 224 | db := openTempDB(t) |
| 225 | for _, col := range []string{ |
| 226 | "auto_run_status", "auto_run_pid", "auto_run_started", |
| 227 | "auto_run_finished", "auto_run_log", |
| 228 | } { |
| 229 | has, err := columnExists(db, "tasks", col) |
| 230 | if err != nil { |
| 231 | t.Fatalf("columnExists(%s): %v", col, err) |
| 232 | } |
| 233 | if !has { |
| 234 | t.Errorf("column %s should exist after migration", col) |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | // Round-trip: write the auto-run fields, scan them back via GetTask. |
| 239 | now := NowISO() |
| 240 | wd := t.TempDir() |
| 241 | if _, err := db.Exec( |
| 242 | `INSERT INTO tasks (slug, name, status, priority, work_dir, session_id, created_at, updated_at, |
| 243 | auto_run_status, auto_run_pid, auto_run_started, auto_run_log) |
| 244 | VALUES (?, ?, 'in-progress', 'medium', ?, 'sess-1', ?, ?, 'running', 4242, ?, '/tmp/run.log')`, |
| 245 | "auto1", "Auto run", wd, now, now, now, |
| 246 | ); err != nil { |
| 247 | t.Fatal(err) |
| 248 | } |
| 249 | got, err := GetTask(db, "auto1") |
| 250 | if err != nil { |
| 251 | t.Fatalf("GetTask: %v", err) |
| 252 | } |
| 253 | if got.AutoRunStatus.String != "running" { |
| 254 | t.Errorf("AutoRunStatus = %q, want running", got.AutoRunStatus.String) |
| 255 | } |
| 256 | if !got.AutoRunPID.Valid || got.AutoRunPID.Int64 != 4242 { |
| 257 | t.Errorf("AutoRunPID = %+v, want 4242", got.AutoRunPID) |
| 258 | } |
| 259 | if got.AutoRunLog.String != "/tmp/run.log" { |
| 260 | t.Errorf("AutoRunLog = %q, want /tmp/run.log", got.AutoRunLog.String) |
| 261 | } |
| 262 | if got.AutoRunFinished.Valid { |
| 263 | t.Errorf("AutoRunFinished should be NULL while running; got %q", got.AutoRunFinished.String) |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | // TestOpenDBOnPreMigrationDB simulates an existing user upgrading from a |
| 268 | // pre-feat/playbooks flow.db: tasks table exists but lacks the kind and |
nothing calls this directly
no test coverage detected