diff --git a/internal/datastore/proxy/schemacaching/standardcaching_test.go b/internal/datastore/proxy/schemacaching/standardcaching_test.go index e89ea38c44..66f60c1da8 100644 --- a/internal/datastore/proxy/schemacaching/standardcaching_test.go +++ b/internal/datastore/proxy/schemacaching/standardcaching_test.go @@ -531,20 +531,19 @@ func TestInvalidEntriesInCache(t *testing.T) { headRevision, err := ds.HeadRevision(ctx) require.NoError(err) - var dsReader definitionCachingReader - dsReader = ds.SnapshotReader(headRevision) - - // Lookup an invalid name - readerReturningNil := func(ctx context.Context, names []string) ([]datastore.RevisionedNamespace, error) { - return []datastore.RevisionedNamespace{{nil, nil}}, nil - } - found, err := listAndCache(ctx, &dsReader, namespaceCacheKeyPrefix, []string{invalidNamespace}, readerReturningNil, estimatedNamespaceDefinitionSize) - require.Empty(found) - require.NoError(err) + dsReader := ds.SnapshotReader(headRevision) + + namespace, _, err := dsReader.ReadNamespaceByName(ctx, invalidNamespace) + require.Nil(namespace) + // NOTE: we're expecting this to error, because the namespace doesn't exist. + // However, the act of calling it sets the cache value to nil, which means that + // subsequent calls to the cache return that nil value. That's what needed to + // be filtered out of the list call. + require.Error(err) // Look it up again - in the bug that this captures, // it was populated into the cache and came back out. - found, err = dsReader.LookupNamespacesWithNames() + found, err := dsReader.LookupNamespacesWithNames(ctx, []string{invalidNamespace}) require.Empty(found) require.NoError(err) }