Add recursive ls
Change-Id: Ifab8c9577c01cf7a96cda8d79fe232b12b5538bd
diff --git a/tests/ls.cpp b/tests/ls.cpp
index 9356c69..e3287ee 100644
--- a/tests/ls.cpp
+++ b/tests/ls.cpp
@@ -36,7 +36,14 @@
SECTION("no arguments")
{
- input = "ls";
+ SECTION("ls")
+ input = "ls";
+
+ SECTION("ls --recursive")
+ {
+ input = "ls --recursive";
+ expected.m_options.push_back(LsOption::Recursive);
+ }
}
SECTION("with path argument")
@@ -110,12 +117,23 @@
expected.m_path = path_{Scope::Absolute, {node_(module_{"example"}, container_{"a"}),
node_(module_{"example"}, container_{"a2"})}};
}
+
+ SECTION("ls --recursive /example:a")
+ {
+ SECTION("cwd: /") {}
+ SECTION("cwd: /example:a") {parser.changeNode(path_{Scope::Relative, {node_(module_{"example"}, container_{"a"})}});}
+
+ input = "ls --recursive /example:a";
+ expected.m_options.push_back(LsOption::Recursive);
+ expected.m_path = path_{Scope::Absolute, {node_(module_{"example"}, container_{"a"})}};
+ }
}
command_ command = parser.parseCommand(input, errorStream);
REQUIRE(command.type() == typeid(ls_));
REQUIRE(boost::get<ls_>(command) == expected);
}
+
SECTION("invalid input")
{
SECTION("invalid path")
@@ -129,13 +147,31 @@
SECTION("ls /bad:nonexistent")
input = "ls /bad:nonexistent";
- SECTION( "ls example:a/nonexistent")
+ SECTION("ls example:a/nonexistent")
input = "ls example:a/nonexistent";
- SECTION( "ls /example:a/nonexistent")
+ SECTION("ls /example:a/nonexistent")
input = "ls /example:a/nonexistent";
}
+ SECTION("whitespace before path")
+ {
+ SECTION("ls --recursive/")
+ input = "ls --recursive/";
+
+ SECTION("ls/")
+ input = "ls/";
+
+ SECTION("ls --recursive/example:a")
+ input = "ls --recursive/example:a";
+
+ SECTION("ls/example:a")
+ input = "ls/example:a";
+
+ SECTION("lssecond:a")
+ input = "lssecond:a";
+ }
+
REQUIRE_THROWS(parser.parseCommand(input, errorStream));
}
}
diff --git a/tests/yang.cpp b/tests/yang.cpp
index 09bef03..6f63bfc 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -288,7 +288,7 @@
set = {"example-schema:a2", "example-schema:leafa"};
}
- REQUIRE(ys.childNodes(path) == set);
+ REQUIRE(ys.childNodes(path, Recursion::NonRecursive) == set);
}
}