Complete slash after lists when inputting "any" path
Choosing what to complete based on what kind of node we're parsing is no
longer suitable. Example is a path ending with list. That kind of path
is by itself a data path, so it gets completed by a left bracket,
however, if we're using the `ls` command, we would like it to complete a
slash. That's why there is now a separate template argument for
NodeParser (and PathParser), which controls the completion mode.
Change-Id: Ib8c9e502f7d57aa88fe0087e7a940370b422ad40
diff --git a/tests/path_completion.cpp b/tests/path_completion.cpp
index 71fc917..3002ed7 100644
--- a/tests/path_completion.cpp
+++ b/tests/path_completion.cpp
@@ -38,6 +38,7 @@
schema->addLeaf("/example:twoKeyList", "example:number", yang::Int32{});
schema->addLeaf("/", "example:leafInt", yang::Int32{});
schema->addLeaf("/", "example:readonly", yang::Int32{}, yang::AccessType::ReadOnly);
+ schema->addLeafList("/", "example:addresses", yang::String{});
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.
@@ -67,14 +68,14 @@
SECTION("ls ")
{
input = "ls ";
- expectedCompletions = {"example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:readonly ", "example:ovocezelenina", "example:twoKeyList", "second:amelie/"};
+ expectedCompletions = {"example:addresses/", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list/", "example:ovoce/", "example:readonly ", "example:ovocezelenina/", "example:twoKeyList/", "second:amelie/"};
expectedContextLength = 0;
}
SECTION("ls e")
{
input = "ls e";
- expectedCompletions = {"example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:readonly ", "example:ovocezelenina", "example:twoKeyList"};
+ expectedCompletions = {"example:addresses/", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list/", "example:ovoce/", "example:readonly ", "example:ovocezelenina/", "example:twoKeyList/"};
expectedContextLength = 1;
}
@@ -102,14 +103,14 @@
SECTION("ls /")
{
input = "ls /";
- expectedCompletions = {"example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:readonly ", "example:ovocezelenina", "example:twoKeyList", "second:amelie/"};
+ expectedCompletions = {"example:addresses/", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list/", "example:ovoce/", "example:readonly ", "example:ovocezelenina/", "example:twoKeyList/", "second:amelie/"};
expectedContextLength = 0;
}
SECTION("ls /e")
{
input = "ls /e";
- expectedCompletions = {"example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:readonly ", "example:ovocezelenina", "example:twoKeyList"};
+ expectedCompletions = {"example:addresses/", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list/", "example:ovoce/", "example:readonly ", "example:ovocezelenina/", "example:twoKeyList/"};
expectedContextLength = 1;
}
@@ -134,6 +135,13 @@
expectedContextLength = 1;
}
+ SECTION("ls /example:list")
+ {
+ input = "ls /example:list";
+ expectedCompletions = {"example:list/"};
+ expectedContextLength = 12;
+ }
+
SECTION("ls /example:list/")
{
input = "ls /example:list/";