(t *testing.T)
| 442 | } |
| 443 | |
| 444 | func 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. |
| 474 | type catalogFakeFetcher struct{} |
nothing calls this directly
no test coverage detected