flake-update-20260201
 1package sources
 2
 3import (
 4	"context"
 5	"os"
 6	"path/filepath"
 7	"testing"
 8	"time"
 9
10	"github.com/vdemeester/home/tools/review-tool/internal/config"
11)
12
13func TestClaudeSource_RealHistory(t *testing.T) {
14	// This test uses the real Claude history directory
15	home, _ := os.UserHomeDir()
16	historyDir := filepath.Join(home, ".config", "claude", "history")
17
18	if _, err := os.Stat(historyDir); err != nil {
19		t.Skipf("Claude history not found at %s", historyDir)
20	}
21
22	cfg := &config.ClaudeConfig{
23		Enabled:          true,
24		HistoryDir:       historyDir,
25		IncludeSessions:  true,
26		IncludeLearnings: true,
27		IncludeResearch:  true,
28	}
29
30	source := NewClaudeSource(cfg)
31
32	// Last 7 days
33	now := time.Now()
34	start := time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, now.Location())
35
36	t.Logf("Range: %s to %s", start.Format("2006-01-02"), now.Format("2006-01-02"))
37
38	act, err := source.Fetch(context.Background(), start, now)
39	if err != nil {
40		t.Fatalf("Fetch error: %v", err)
41	}
42
43	t.Logf("Found %d items", len(act.Items))
44	for i, item := range act.Items {
45		if i < 10 {
46			t.Logf("  [%s] %s (%s)", item.Type, item.Title, item.Timestamp.Format("2006-01-02"))
47		}
48	}
49
50	// Should find at least some items in the last 7 days
51	if len(act.Items) == 0 {
52		t.Error("Expected to find some Claude history items")
53	}
54}