-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix virtual document cache invalidation
The virtual document cache was not being invalidated. As a result, if the same rule was evaluated twice where the first expression included a with modifier, the result on the second evaluation may be incorrect. Fixes #736 Signed-off-by: Torin Sandall <[email protected]>
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2018 The OPA Authors. All rights reserved. | ||
// Use of this source code is governed by an Apache2 | ||
// license that can be found in the LICENSE file. | ||
|
||
package topdown | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/open-policy-agent/opa/ast" | ||
) | ||
|
||
func TestVirtualCacheInvalidate(t *testing.T) { | ||
cache := newVirtualCache() | ||
cache.Push() | ||
cache.Put(ast.MustParseRef("data.x.p"), ast.BooleanTerm(true)) | ||
cache.Pop() | ||
result := cache.Get(ast.MustParseRef("data.x.p")) | ||
if result != nil { | ||
t.Fatal("Expected nil result but got:", result) | ||
} | ||
} |