Integrate DataQuery

Change-Id: I439374afe485baf08a4d5a1a02fd70d908bec9e1
diff --git a/tests/path_completion.cpp b/tests/path_completion.cpp
index 832110d..0ad6089 100644
--- a/tests/path_completion.cpp
+++ b/tests/path_completion.cpp
@@ -7,6 +7,7 @@
 */
 
 #include "trompeloeil_doctest.h"
+#include "datastoreaccess_mock.hpp"
 #include "parser.hpp"
 #include "pretty_printers.hpp"
 #include "static_schema.hpp"
@@ -36,7 +37,20 @@
     schema->addLeaf("/example:twoKeyList", "example:name", yang::LeafDataTypes::String);
     schema->addLeaf("/example:twoKeyList", "example:number", yang::LeafDataTypes::Int32);
     schema->addLeaf("/", "example:leafInt", yang::LeafDataTypes::Int32);
-    Parser parser(schema);
+    auto mockDatastore = std::make_shared<MockDatastoreAccess>();
+
+    // The parser will use DataQuery for key value completion, but I'm not testing that here, so I don't return anything.
+    ALLOW_CALL(*mockDatastore, listInstances("/example:list"))
+        .RETURN(std::vector<ListInstance>{});
+    ALLOW_CALL(*mockDatastore, listInstances("/example:twoKeyList"))
+        .RETURN(std::vector<ListInstance>{});
+
+    // DataQuery gets the schema from DatastoreAccess once
+    auto expectation = NAMED_REQUIRE_CALL(*mockDatastore, schema())
+        .RETURN(schema);
+    auto dataQuery = std::make_shared<DataQuery>(*mockDatastore);
+    expectation.reset();
+    Parser parser(schema, dataQuery);
     std::string input;
     std::ostringstream errorStream;
 
@@ -188,8 +202,8 @@
         SECTION("cd example:list[number=")
         {
             input = "cd example:list[number=";
-            expectedCompletions = {"number="};
-            expectedContextLength = 7;
+            expectedCompletions = {};
+            expectedContextLength = 0;
         }
 
         SECTION("cd example:list[number=12")