Skip to content

Commit

Permalink
Write the correct test'
Browse files Browse the repository at this point in the history
  • Loading branch information
tstirrat15 committed Nov 28, 2024
1 parent 45056bd commit 0a4c384
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions internal/datastore/proxy/schemacaching/standardcaching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 0a4c384

Please sign in to comment.