mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
Fix string formatting on storage error
This commit is contained in:
+1
-1
@@ -179,7 +179,7 @@ func (s *Storage) Read(txn Transaction, path ast.Ref) (interface{}, error) {
|
||||
}
|
||||
|
||||
if !path.IsGround() {
|
||||
return nil, internalError("non-ground reference:", path)
|
||||
return nil, internalError("non-ground reference: %v", path)
|
||||
}
|
||||
|
||||
holes := []hole{}
|
||||
|
||||
@@ -12,6 +12,21 @@ import (
|
||||
"github.com/open-policy-agent/opa/ast"
|
||||
)
|
||||
|
||||
func TestStorageReadNonGroundRef(t *testing.T) {
|
||||
store := New(InMemoryConfig())
|
||||
txn := NewTransactionOrDie(store)
|
||||
defer store.Close(txn)
|
||||
ref := ast.MustParseRef("data.foo[i]")
|
||||
_, e := store.Read(txn, ref)
|
||||
err, ok := e.(*Error)
|
||||
if !ok {
|
||||
t.Fatalf("Expected storage error but got: %v", err)
|
||||
}
|
||||
if err.Code != InternalErr {
|
||||
t.Fatalf("Expected internal error but got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStorageReadPlugin(t *testing.T) {
|
||||
|
||||
mem1 := NewDataStoreFromReader(strings.NewReader(`
|
||||
|
||||
Reference in New Issue
Block a user