package main import ( "context" "strings" "testing" "time" "git.novox.be/novox/mesh-sdk/go/catalogue" sdkdelivery "git.novox.be/novox/mesh-sdk/go/delivery" "github.com/novox/mesh-controller/internal/inventory" ) // A10 (ADR 0501 ยง6; issue 1851): a module the catalogue does not hold and the indexer does is one whose key is coming: // an assignment of it waits for that key, named by the module, with no build asked and no build request read. func TestAModuleTheIndexerHoldsIsWaitedForByItsKey(t *testing.T) { was := indexedModule indexedModule = func(_ context.Context, module string) (sdkdelivery.Module, bool, error) { return sdkdelivery.Module{Repository: "novox/mesh-catalog", Commit: "3da80a4b00aa", Path: "modules/" + module}, true, nil } t.Cleanup(func() { indexedModule = was }) where, err := whereIs(t.Context(), noRequests{}, "sensors", time.Now()) if err != nil { t.Fatal(err) } if where.kind != keyComing || where.request.ID != keyPendingPrefix+"sensors" || where.request.Path != "modules/sensors" || !strings.Contains(where.said, "registered from the builder's done key") { t.Fatalf("a module whose key is coming is read as %+v", where) } } // noRequests is records with no build request and no module: what a mesh after R4e reads of a new module. type noRequests struct{} func (noRequests) RequestsNamed(context.Context, string) ([]inventory.RequestOutcome, error) { return nil, nil } func (noRequests) Catalogue(context.Context) (map[string]catalogue.Manifest, error) { return nil, nil } func (noRequests) RequestedNames(context.Context) ([]string, error) { return nil, nil }