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

Function TestRefreshAll

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

Source from the content-addressed store, hash-verified

442}
443
444func TestRefreshAll(t *testing.T) {
445 ctx := context.Background()
446 dir := t.TempDir()
447 t.Setenv("HOME", dir)
448 t.Setenv("CAM_CACHE_DIR", filepath.Join(dir, "cache"))
449 s := NewStore(filepath.Join(dir, "cam.db"))
450
451 svc := NewService(s).WithFetcher(fakeFetcher{})
452 summary, err := svc.RefreshAll(ctx)
453 if err != nil {
454 t.Fatalf("RefreshAll: %v", err)
455 }
456 if summary.ItemsAdded == 0 {
457 t.Fatal("expected resources discovered from repos")
458 }
459
460 // Every kind, including instructions, should be represented.
461 for _, kind := range []string{"skill", "agent", "instruction", "plugin"} {
462 results, _ := s.Search(ctx, SearchQuery{Query: "", Kind: kind})
463 if len(results) == 0 {
464 t.Fatalf("expected %s results after refresh", kind)
465 }
466 // Items are individual resources, not repos: install_key has a ":name" suffix.
467 if kind == "skill" && !strings.Contains(results[0].InstallKey, ":") {
468 t.Fatalf("expected resource-level install_key, got %q", results[0].InstallKey)
469 }
470 }
471}
472
473// catalogFakeFetcher writes generated catalog files instead of installable manifests.
474type catalogFakeFetcher struct{}

Callers

nothing calls this directly

Calls 5

SearchMethod · 0.95
NewServiceFunction · 0.85
WithFetcherMethod · 0.80
RefreshAllMethod · 0.80
NewStoreFunction · 0.70

Tested by

no test coverage detected