(t *testing.T)
| 981 | |
| 982 | // TestCmdDoHereForceOverwritesBinding pins that --force allows the |
| 983 | // overwrite of a prior binding. The user has been told this orphans |
| 984 | // the prior session. |
| 985 | func TestCmdDoHereForceOverwritesBinding(t *testing.T) { |
| 986 | setupFlowRoot(t) |
| 987 | // Force-rebind still needs to satisfy the cwd-matches-work_dir |
| 988 | // invariant — the new session must have been started at work_dir. |
| 989 | seedTaskAtCwd(t, "force-task") |
| 990 | stubClaudeStatOK(t) |
| 991 | |
| 992 | const oldSID = "deadbeef-1111-4222-8333-444455556666" |
| 993 | const newSID = "f00ba111-2222-4333-8444-555555555555" |
| 994 | db := openFlowDB(t) |
| 995 | if _, err := db.Exec( |
| 996 | `UPDATE tasks SET session_id=?, session_started=?, status='in-progress' WHERE slug='force-task'`, |
| 997 | oldSID, flowdb.NowISO(), |
| 998 | ); err != nil { |
| 999 | t.Fatal(err) |
| 1000 | } |
| 1001 | db.Close() |
| 1002 | |
| 1003 | t.Setenv("CLAUDE_CODE_SESSION_ID", newSID) |
| 1004 | if rc := cmdDo([]string{"force-task", "--here", "--force"}); rc != 0 { |
| 1005 | t.Errorf("rc=%d, want 0 with --force", rc) |
| 1006 | } |
| 1007 | db = openFlowDB(t) |
| 1008 | task, _ := flowdb.GetTask(db, "force-task") |
| 1009 | if task.SessionID.String != newSID { |
| 1010 | t.Errorf("session_id after --force: got %q, want %s", task.SessionID.String, newSID) |
| 1011 | } |
| 1012 | } |
nothing calls this directly
no test coverage detected