Fix string formatting on storage error

This commit is contained in:
Torin Sandall
2016-10-26 10:13:49 -07:00
parent 98ab3fb44a
commit d713638d8c
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -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{}
+15
View File
@@ -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(`