37 lines
1011 B
Go
37 lines
1011 B
Go
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestChatRecoveryJournalIsNotConsumedAndKeepsUnverifiedAttention(t *testing.T) {
|
|
s, err := Open(filepath.Join(t.TempDir(), "live.db"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer s.Close()
|
|
ctx := context.Background()
|
|
if err := s.RememberChatLiveSession(ctx, ChatLiveSession{SessionID: "ses_task", Attention: true}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// Ending the foreground turn/evicting its replay is not task completion.
|
|
if err := s.RememberChatLiveSession(ctx, ChatLiveSession{SessionID: "ses_task"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for i := 0; i < 2; i++ {
|
|
got, err := s.ChatLiveSessions(ctx)
|
|
if err != nil || len(got) != 1 || !got[0].Attention || got[0].Turn {
|
|
t.Fatalf("read%d: %+v %v", i, got, err)
|
|
}
|
|
}
|
|
if err := s.ForgetChatLiveSession(ctx, "ses_task"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got, err := s.ChatLiveSessions(ctx)
|
|
if err != nil || len(got) != 0 {
|
|
t.Fatalf("confirmed idle retained: %+v %v", got, err)
|
|
}
|
|
}
|