MCPcopy Create free account
hub / github.com/compozy/agh / TestMultiRegistryValidationAndFallbackErrors

Function TestMultiRegistryValidationAndFallbackErrors

internal/registry/multi_test.go:491–540  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

489}
490
491func TestMultiRegistryValidationAndFallbackErrors(t *testing.T) {
492 t.Parallel()
493
494 t.Run("Should search respects canceled context", func(t *testing.T) {
495 ctx, cancel := context.WithCancel(context.Background())
496 cancel()
497
498 err := checkMultiRegistryContext(ctx)
499 if !errors.Is(err, context.Canceled) {
500 t.Fatalf("checkMultiRegistryContext(canceled) error = %v, want context.Canceled", err)
501 }
502 })
503
504 t.Run("Should info requires slug", func(t *testing.T) {
505 _, err := NewMultiRegistry(testLogger(), &stubRegistrySource{name: "source"}).Info(context.Background(), " ")
506 if err == nil {
507 t.Fatal("Info(blank slug) error = nil, want non-nil")
508 }
509 })
510
511 t.Run("Should info returns not found when no source resolves slug", func(t *testing.T) {
512 _, err := NewMultiRegistry(
513 testLogger(),
514 &stubRegistrySource{name: "source"},
515 ).Info(context.Background(), "missing")
516 if err == nil {
517 t.Fatal("Info(missing) error = nil, want non-nil")
518 }
519 if !strings.Contains(err.Error(), "not found") {
520 t.Fatalf("Info(missing) error = %v, want not found context", err)
521 }
522 })
523
524 t.Run("Should download rejects nil result", func(t *testing.T) {
525 registry := NewMultiRegistry(testLogger(), &stubRegistrySource{
526 name: "source",
527 infoFunc: func(context.Context, string) (*Detail, error) {
528 return &Detail{Listing: Listing{Slug: "pkg"}}, nil
529 },
530 downloadFunc: func(context.Context, string, DownloadOpts) (*DownloadResult, error) {
531 return nil, nil
532 },
533 })
534
535 _, err := registry.Download(context.Background(), "pkg", DownloadOpts{})
536 if err == nil {
537 t.Fatal("Download(nil result) error = nil, want non-nil")
538 }
539 })
540}
541
542func TestMultiRegistryHelperFunctions(t *testing.T) {
543 t.Parallel()

Callers

nothing calls this directly

Calls 9

DownloadMethod · 0.95
NewMultiRegistryFunction · 0.85
testLoggerFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
InfoMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected