Skip to content

Commit 24c6db1

Browse files
committed
Fixups
1 parent 9eb78b3 commit 24c6db1

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

test/e2e/source_manager_test.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,23 @@ var _ = Describe("SourceManager", func() {
180180
err := sourceManager.AddSource(TestCollection, complexURL, DefaultUpdateInterval)
181181
Expect(err).To(BeNil())
182182

183-
// Verify the source was added with sanitized filename
184-
sources := kb.GetExternalSources()
185-
Expect(sources).To(HaveLen(1))
186-
Expect(sources[0].URL).To(Equal(complexURL))
183+
sourceManager.Start()
184+
defer sourceManager.Stop()
185+
186+
// Wait for initial content to be fetched
187+
Eventually(func() []string {
188+
return kb.ListDocuments()
189+
}, TestTimeout, TestPollingInterval).Should(HaveLen(1))
190+
191+
// Let it run for 2 minutes and check for duplicates
192+
Consistently(func() []string {
193+
return kb.ListDocuments()
194+
}, 2*time.Minute, 5*time.Second).Should(HaveLen(1))
187195

188196
// List documents to verify the sanitized filename
189197
docs := kb.ListDocuments()
190198
Expect(docs).To(HaveLen(1))
191-
Expect(docs[0]).To(ContainSubstring("example-com-path-query-value-param-123-section"))
199+
Expect(docs[0]).To(ContainSubstring("source-foo-https-example-com-path-query-value-param-123-section.txt"))
192200
})
193201
})
194202

@@ -228,7 +236,7 @@ var _ = Describe("SourceManager", func() {
228236

229237
It("should prevent duplicate content with frequent updates", func() {
230238
// Add a source with a very short update interval
231-
err := sourceManager.AddSource(TestCollection, "https://raw.githubusercontent.com/mudler/LocalRecall/main/README.md", 1*time.Second)
239+
err := sourceManager.AddSource(TestCollection, "https://en.wikipedia.org/wiki/Black-crowned_barwing", 1*time.Second)
232240
Expect(err).To(BeNil())
233241

234242
// Start the background service
@@ -237,19 +245,23 @@ var _ = Describe("SourceManager", func() {
237245
// Wait for initial content to be fetched
238246
Eventually(func() []string {
239247
return kb.ListDocuments()
240-
}, TestTimeout, TestPollingInterval).Should(HaveLen(1))
248+
}, 2*time.Minute, 5*time.Second).Should(HaveLen(1))
241249

242250
// Let it run for 2 minutes and check for duplicates
243-
Consistently(func() []string {
244-
return kb.ListDocuments()
245-
}, 2*time.Minute, 5*time.Second).Should(HaveLen(1))
251+
Consistently(func() int {
252+
e, ok := kb.Engine.(*engine.ChromemDB)
253+
Expect(ok).To(BeTrue())
254+
return e.Count()
255+
}, 3*time.Minute, 5*time.Second).Should(Equal(25))
246256

247257
// Verify that search results don't contain duplicates
248258
Consistently(func() bool {
249-
results, err := kb.Engine.Search("What is LocalRecall?", 10)
259+
results, err := kb.Engine.Search("What is the Black-crowned barwing?", 3)
250260
if err != nil {
261+
fmt.Println("Error searching for content", err)
251262
return false
252263
}
264+
253265
// Check for duplicate content
254266
seen := make(map[string]bool)
255267
for _, r := range results {

0 commit comments

Comments
 (0)