37 lines
969 B
Go
37 lines
969 B
Go
package taskrun
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestListActiveBySession_MemoryOnly(t *testing.T) {
|
|
m := NewManager(nil, nil)
|
|
m.mu.Lock()
|
|
m.runs["run-live"] = &activeRun{record: &RunRecord{
|
|
RunID: "run-live", SessionID: "sess-1", Status: "running", TaskKey: "research",
|
|
}}
|
|
m.runs["run-done"] = &activeRun{record: &RunRecord{
|
|
RunID: "run-done", SessionID: "sess-1", Status: "completed",
|
|
}}
|
|
m.runs["other"] = &activeRun{record: &RunRecord{
|
|
RunID: "other", SessionID: "sess-2", Status: "running",
|
|
}}
|
|
m.mu.Unlock()
|
|
|
|
listed, err := m.ListActiveBySession(context.Background(), "sess-1")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(listed) != 1 || listed[0].RunID != "run-live" {
|
|
t.Fatalf("listed = %#v", listed)
|
|
}
|
|
}
|
|
|
|
func TestWriteRunningAnchor_NoContextManagerIsNoop(t *testing.T) {
|
|
m := NewManager(nil, nil)
|
|
m.writeRunningAnchor(context.Background(), &RunRecord{
|
|
RunID: "run-1", AssistantMsgID: 9, TaskKey: "research", Status: "running",
|
|
})
|
|
}
|