Refine Telegram thread commands
This commit is contained in:
@@ -109,6 +109,42 @@ func TestStoreUsersWorkspacesSessions(t *testing.T) {
|
||||
if session.ActiveTurnID != "" {
|
||||
t.Fatalf("active turn not cleared: %+v", session)
|
||||
}
|
||||
if err := st.SetActiveThread(ctx, 42, thread.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := st.SetActiveTurn(ctx, 42, "turn-delete"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := st.DeleteThread(ctx, 42, thread.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
session, err = st.GetSession(ctx, 42)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if session.ActiveThreadID != 0 || session.ActiveTurnID != "" {
|
||||
t.Fatalf("delete should clear active thread and turn: %+v", session)
|
||||
}
|
||||
if _, err := st.GetThreadByID(ctx, 42, thread.ID); err == nil {
|
||||
t.Fatal("deleted thread should not be found")
|
||||
}
|
||||
thread, err = st.CreateThread(ctx, 42, "codex-thread-delete-by-id", ws.ID, "delete by codex id")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := st.SetActiveThread(ctx, 42, thread.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := st.DeleteThreadByCodexID(ctx, "codex-thread-delete-by-id"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
session, err = st.GetSession(ctx, 42)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if session.ActiveThreadID != 0 {
|
||||
t.Fatalf("delete by codex id should clear active thread: %+v", session)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListThreadsPage(t *testing.T) {
|
||||
@@ -142,6 +178,26 @@ func TestListThreadsPage(t *testing.T) {
|
||||
if len(threads) != 1 {
|
||||
t.Fatalf("got %d threads on second page, want 1", len(threads))
|
||||
}
|
||||
if err := st.ArchiveThread(ctx, 42, threads[0].ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
archived, err := st.ListArchivedThreadsPage(ctx, 42, 10, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(archived) != 1 || !archived[0].Archived {
|
||||
t.Fatalf("archived threads = %+v, want one archived thread", archived)
|
||||
}
|
||||
if err := st.UnarchiveThread(ctx, 42, archived[0].ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
archived, err = st.ListArchivedThreadsPage(ctx, 42, 10, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(archived) != 0 {
|
||||
t.Fatalf("archived threads after unarchive = %+v, want none", archived)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenameThread(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user