Add thread rename support
This commit is contained in:
@@ -120,6 +120,44 @@ func TestListThreadsPage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenameThread(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
st, err := Open(ctx, filepath.Join(t.TempDir(), "bot.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer st.Close()
|
||||
|
||||
ws, err := st.AddWorkspace(ctx, t.TempDir(), "repo", true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread, err := st.CreateThread(ctx, 42, "codex-thread", ws.ID, "old title")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := st.RenameThread(ctx, 42, thread.ID, "new title"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread, err = st.GetThreadByID(ctx, 42, thread.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if thread.Title != "new title" {
|
||||
t.Fatalf("title = %q", thread.Title)
|
||||
}
|
||||
if err := st.RenameThreadByCodexID(ctx, "codex-thread", "codex title"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread, err = st.GetThreadByID(ctx, 42, thread.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if thread.Title != "codex title" {
|
||||
t.Fatalf("title = %q", thread.Title)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateWorkspacePath(t *testing.T) {
|
||||
if _, err := ValidateWorkspacePath("relative/path"); err == nil {
|
||||
t.Fatal("relative path should be rejected")
|
||||
|
||||
Reference in New Issue
Block a user