Skip to content

Commit c27f9de

Browse files
committed
fix tests
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 3ebbdcc commit c27f9de

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

pkg/client/client.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,20 @@ func (c *Client) ListCollections() ([]string, error) {
6666
return nil, errors.New("failed to list collections")
6767
}
6868

69-
var collections []string
70-
err = json.NewDecoder(resp.Body).Decode(&collections)
69+
var apiResp struct {
70+
Success bool `json:"success"`
71+
Message string `json:"message"`
72+
Data struct {
73+
Collections []string `json:"collections"`
74+
Count int `json:"count"`
75+
} `json:"data"`
76+
}
77+
err = json.NewDecoder(resp.Body).Decode(&apiResp)
7178
if err != nil {
7279
return nil, err
7380
}
7481

75-
return collections, nil
82+
return apiResp.Data.Collections, nil
7683
}
7784

7885
// ListEntries lists all entries in a collection

rag/source_manager.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ func (sm *SourceManager) RemoveSource(collectionName, url string) error {
102102
}
103103

104104
if err := collection.RemoveEntry(fmt.Sprintf("source-%s-%s.txt", collectionName, sanitizeURL(url))); err != nil {
105-
return err
105+
// Ignore error if entry doesn't exist — content may never have been fetched
106+
if err.Error() != "entry not found" {
107+
return err
108+
}
106109
}
107110

108111
// Remove from in-memory sources

test/e2e/persistency_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ var _ = Describe("Persistency", func() {
111111

112112
docs := kb.ListDocuments()
113113
Expect(docs).To(HaveLen(1))
114-
Expect(docs[0]).To(Equal("test.txt"))
114+
Expect(docs[0]).To(ContainSubstring("test.txt"))
115115
})
116116

117117
It("should get entry content", func() {

0 commit comments

Comments
 (0)