MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / TestSearchPagination

Function TestSearchPagination

internal/metadata/store_test.go:134–160  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

132}
133
134func TestSearchPagination(t *testing.T) {
135 ctx := context.Background()
136 s := NewStore(filepath.Join(t.TempDir(), "cam.db"))
137 s.Init(ctx)
138 // Insert 5 items.
139 for i := range 5 {
140 s.UpsertItem(ctx, Item{Kind: "skill", Name: fmt.Sprintf("page-skill-%d", i), InstallKey: fmt.Sprintf("a/b:page-%d", i)})
141 }
142
143 // Page 1: limit 2, offset 0 → 2 items.
144 page1, _ := s.Search(ctx, SearchQuery{Query: "page-skill", Kind: "skill", Limit: 2, Offset: 0})
145 if len(page1) != 2 {
146 t.Fatalf("page1 expected 2 items, got %d", len(page1))
147 }
148
149 // Page 3: limit 2, offset 4 → 1 item (the last).
150 page3, _ := s.Search(ctx, SearchQuery{Query: "page-skill", Kind: "skill", Limit: 2, Offset: 4})
151 if len(page3) != 1 {
152 t.Fatalf("page3 expected 1 item, got %d", len(page3))
153 }
154
155 // Count should be 5.
156 count, _ := s.Count(ctx, SearchQuery{Query: "page-skill", Kind: "skill"})
157 if count != 5 {
158 t.Fatalf("count expected 5, got %d", count)
159 }
160}
161
162// upsertSkill is a small helper for the dedup tests below.
163func upsertSkill(t *testing.T, ctx context.Context, s *Store, name, owner, repo, installKey string) {

Callers

nothing calls this directly

Calls 5

InitMethod · 0.95
UpsertItemMethod · 0.95
SearchMethod · 0.95
CountMethod · 0.95
NewStoreFunction · 0.70

Tested by

no test coverage detected