blob: be676c9ee8d3244915845d90fe3601dbc08e986a [file] [log] [blame]
Václav Kubernát4108e0d2018-10-29 13:32:22 +01001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
3 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
4 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
8
Václav Kubernát26b56082020-02-03 18:28:56 +01009#include "trompeloeil_doctest.hpp"
Václav Kubernát43908fb2020-01-02 19:05:51 +010010#include "datastoreaccess_mock.hpp"
Václav Kubernát4108e0d2018-10-29 13:32:22 +010011#include "parser.hpp"
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010012#include "pretty_printers.hpp"
Václav Kubernát4108e0d2018-10-29 13:32:22 +010013#include "static_schema.hpp"
14
15TEST_CASE("path_completion")
16{
17 auto schema = std::make_shared<StaticSchema>();
18 schema->addModule("example");
19 schema->addModule("second");
Václav Kubernátefcac932020-01-10 15:26:32 +010020 schema->addContainer("/", "example:ano");
21 schema->addContainer("/", "example:anoda");
22 schema->addList("/example:ano", "example:listInCont", {"number"});
23 schema->addContainer("/", "second:amelie");
24 schema->addContainer("/", "example:bota");
25 schema->addContainer("/example:ano", "example:a2");
26 schema->addContainer("/example:bota", "example:b2");
27 schema->addContainer("/example:ano/example:a2", "example:a3");
28 schema->addContainer("/example:bota/example:b2", "example:b3");
29 schema->addList("/", "example:list", {"number"});
Václav Kubernát3a99f002020-03-31 02:27:41 +020030 schema->addLeaf("/example:list", "example:number", yang::Int32{});
Václav Kubernátefcac932020-01-10 15:26:32 +010031 schema->addContainer("/example:list", "example:contInList");
Václav Kubernát7707cae2020-01-16 12:04:53 +010032 schema->addList("/", "example:ovoce", {"name"});
Václav Kubernát3a99f002020-03-31 02:27:41 +020033 schema->addLeaf("/example:ovoce", "example:name", yang::String{});
Václav Kubernát7707cae2020-01-16 12:04:53 +010034 schema->addList("/", "example:ovocezelenina", {"name"});
Václav Kubernát3a99f002020-03-31 02:27:41 +020035 schema->addLeaf("/example:ovocezelenina", "example:name", yang::String{});
Václav Kubernátefcac932020-01-10 15:26:32 +010036 schema->addList("/", "example:twoKeyList", {"number", "name"});
Václav Kubernát3a99f002020-03-31 02:27:41 +020037 schema->addLeaf("/example:twoKeyList", "example:name", yang::String{});
38 schema->addLeaf("/example:twoKeyList", "example:number", yang::Int32{});
39 schema->addLeaf("/", "example:leafInt", yang::Int32{});
Václav Kubernátabf52802020-05-19 01:31:17 +020040 schema->addLeaf("/", "example:readonly", yang::Int32{}, yang::AccessType::ReadOnly);
Václav Kubernát743d9eb2020-05-18 13:42:36 +020041 schema->addLeafList("/", "example:addresses", yang::String{});
Václav Kubernáte7248b22020-06-26 15:38:59 +020042 schema->addRpc("/", "second:fire");
43 schema->addLeaf("/second:fire", "second:whom", yang::String{});
Václav Kubernátce108db2021-01-25 10:05:40 +010044 schema->addContainer("/", "example:system");
45 schema->addContainer("/example:system", "example:thing");
46 schema->addContainer("/", "example:system-state");
Václav Kubernát43908fb2020-01-02 19:05:51 +010047 auto mockDatastore = std::make_shared<MockDatastoreAccess>();
48
49 // The parser will use DataQuery for key value completion, but I'm not testing that here, so I don't return anything.
50 ALLOW_CALL(*mockDatastore, listInstances("/example:list"))
51 .RETURN(std::vector<ListInstance>{});
52 ALLOW_CALL(*mockDatastore, listInstances("/example:twoKeyList"))
53 .RETURN(std::vector<ListInstance>{});
54
55 // DataQuery gets the schema from DatastoreAccess once
56 auto expectation = NAMED_REQUIRE_CALL(*mockDatastore, schema())
57 .RETURN(schema);
58 auto dataQuery = std::make_shared<DataQuery>(*mockDatastore);
59 expectation.reset();
Václav Kubernát28cf3362020-06-29 17:52:51 +020060 Parser parser(schema, WritableOps::No, dataQuery);
Václav Kubernát4108e0d2018-10-29 13:32:22 +010061 std::string input;
62 std::ostringstream errorStream;
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010063
64 std::set<std::string> expectedCompletions;
65 // GCC complains here with -Wmaybe-uninitialized if I don't assign
66 // something here. I suspect it's because of nested SECTIONs. -1 is an
67 // invalid value (as in, I'll never expect expectedContextLength to be -1),
68 // so let's go with that.
69 int expectedContextLength = -1;
Václav Kubernát4108e0d2018-10-29 13:32:22 +010070
Václav Kubernát329c6c32019-02-06 16:41:53 +010071 SECTION("node name completion")
Václav Kubernát4108e0d2018-10-29 13:32:22 +010072 {
Václav Kubernát329c6c32019-02-06 16:41:53 +010073 SECTION("ls ")
74 {
75 input = "ls ";
Václav Kubernátce108db2021-01-25 10:05:40 +010076 expectedCompletions = {"example:addresses/", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list/", "example:ovoce/", "example:readonly ", "example:ovocezelenina/", "example:twoKeyList/", "second:amelie/", "second:fire/", "example:system/", "example:system-state/"};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010077 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +010078 }
79
80 SECTION("ls e")
81 {
82 input = "ls e";
Václav Kubernátce108db2021-01-25 10:05:40 +010083 expectedCompletions = {"example:addresses/", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list/", "example:ovoce/", "example:readonly ", "example:ovocezelenina/", "example:twoKeyList/", "example:system/", "example:system-state/"};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010084 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +010085 }
86
87 SECTION("ls example:ano")
88 {
89 input = "ls example:ano";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010090 expectedCompletions = {"example:ano/", "example:anoda/"};
91 expectedContextLength = 11;
Václav Kubernát329c6c32019-02-06 16:41:53 +010092 }
93
Václav Kubernáte2d629f2020-04-28 11:01:54 +020094 SECTION("ls example:ano/a")
Václav Kubernát329c6c32019-02-06 16:41:53 +010095 {
Václav Kubernáte2d629f2020-04-28 11:01:54 +020096 input = "ls example:ano/a";
97 expectedCompletions = {"a2/"};
98 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +010099 }
100
101 SECTION("ls x")
102 {
103 input = "ls x";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100104 expectedCompletions = {};
105 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100106 }
107
108 SECTION("ls /")
109 {
110 input = "ls /";
Václav Kubernátce108db2021-01-25 10:05:40 +0100111 expectedCompletions = {"example:addresses/", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list/", "example:ovoce/", "example:readonly ", "example:ovocezelenina/", "example:twoKeyList/", "second:amelie/", "second:fire/", "example:system/", "example:system-state/"};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100112 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100113 }
114
115 SECTION("ls /e")
116 {
117 input = "ls /e";
Václav Kubernátce108db2021-01-25 10:05:40 +0100118 expectedCompletions = {"example:addresses/", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list/", "example:ovoce/", "example:readonly ", "example:ovocezelenina/", "example:twoKeyList/", "example:system/", "example:system-state/"};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100119 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100120 }
121
Václav Kubernáte69133a2019-11-01 19:01:34 +0100122 SECTION("ls example:bota")
123 {
124 input = "ls example:bota";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100125 expectedCompletions = {"example:bota/"};
126 expectedContextLength = 12;
Václav Kubernáte69133a2019-11-01 19:01:34 +0100127 }
128
129 SECTION("ls /example:bota")
130 {
131 input = "ls /example:bota";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100132 expectedCompletions = {"example:bota/"};
133 expectedContextLength = 12;
Václav Kubernáte69133a2019-11-01 19:01:34 +0100134 }
135
Václav Kubernát329c6c32019-02-06 16:41:53 +0100136 SECTION("ls /s")
137 {
138 input = "ls /s";
Václav Kubernáte7248b22020-06-26 15:38:59 +0200139 expectedCompletions = {"second:amelie/", "second:fire/"};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100140 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100141 }
142
Václav Kubernát743d9eb2020-05-18 13:42:36 +0200143 SECTION("ls /example:list")
144 {
145 input = "ls /example:list";
146 expectedCompletions = {"example:list/"};
147 expectedContextLength = 12;
148 }
149
Václav Kubernát26be33a2020-02-13 13:30:14 +0100150 SECTION("ls /example:list/")
151 {
152 input = "ls /example:list/";
Václav Kubernáte2d629f2020-04-28 11:01:54 +0200153 expectedCompletions = {"contInList/", "number "};
Václav Kubernát26be33a2020-02-13 13:30:14 +0100154 expectedContextLength = 0;
155 }
156
Václav Kubernát329c6c32019-02-06 16:41:53 +0100157 SECTION("ls /example:list[number=3]/")
158 {
159 input = "ls /example:list[number=3]/";
Václav Kubernáte2d629f2020-04-28 11:01:54 +0200160 expectedCompletions = {"contInList/", "number "};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100161 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100162 }
163
164 SECTION("ls /example:list[number=3]/c")
165 {
Václav Kubernáte2d629f2020-04-28 11:01:54 +0200166 input = "ls /example:list[number=3]/c";
167 expectedCompletions = {"contInList/"};
168 expectedContextLength = 1;
169 }
170
171 SECTION("ls /example:list[number=3]/n")
172 {
173 input = "ls /example:list[number=3]/n";
174 expectedCompletions = {"number "};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100175 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100176 }
177
178 SECTION("ls /example:list[number=3]/a")
179 {
180 input = "ls /example:list[number=3]/a";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100181 expectedCompletions = {};
182 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100183 }
Václav Kubernát26be33a2020-02-13 13:30:14 +0100184
Václav Kubernáte2d629f2020-04-28 11:01:54 +0200185 SECTION("ls /example:list/contInList/")
Václav Kubernát26be33a2020-02-13 13:30:14 +0100186 {
Václav Kubernáte2d629f2020-04-28 11:01:54 +0200187 input = "ls /example:list/contInList/";
Václav Kubernát26be33a2020-02-13 13:30:14 +0100188 expectedCompletions = {};
189 expectedContextLength = 0;
190 }
Václav Kubernátce108db2021-01-25 10:05:40 +0100191
192 SECTION("ls /example:system-")
193 {
194 input = "ls /example:system-";
195 expectedCompletions = {"example:system-state/"};
196 expectedContextLength = 15;
197 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100198 }
199
Václav Kubernát7eb47152020-11-12 16:57:03 +0100200 SECTION("get completion")
201 {
202 SECTION("get /example:ano/l")
203 {
204 input = "get /example:ano/l";
205 expectedCompletions = {"listInCont"};
206 expectedContextLength = 1;
207 }
Václav Kubernát85ba7382020-11-18 18:11:18 +0100208
209 SECTION("get /example:list/")
210 {
211 input = "get /example:list/";
212 expectedCompletions = {};
213 // The expectedContextLength is 13, because the completion isn't actually generated after the slash.
214 expectedContextLength = 13;
215 }
Václav Kubernáte066fe22022-04-06 00:32:26 +0200216
217 SECTION("get -")
218 {
219 input = "get -";
220 expectedCompletions = {"-datastore "};
221 expectedContextLength = 0;
222 }
223
224 SECTION("get --datastore ")
225 {
226 input = "get --datastore ";
227 expectedCompletions = {"operational", "running", "startup"};
228 expectedContextLength = 0;
229 }
230
231 SECTION("get --datastore running /second")
232 {
233 input = "get --datastore running /second";
234 expectedCompletions = {"second:amelie/"};
235 expectedContextLength = 6;
236 }
Václav Kubernát7eb47152020-11-12 16:57:03 +0100237 }
238
Václav Kubernát3200b862020-12-03 02:34:55 +0100239 SECTION("describe completion")
240 {
241 SECTION("path with list at the end")
242 {
243 input = "describe /example:list/";
244 expectedCompletions = {"contInList/", "number "};
245 expectedContextLength = 0;
246 }
247 }
248
Václav Kubernát329c6c32019-02-06 16:41:53 +0100249 SECTION("list keys completion")
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100250 {
Václav Kubernát329c6c32019-02-06 16:41:53 +0100251 SECTION("cd example:lis")
252 {
253 input = "cd example:lis";
Václav Kubernátcb3af402020-02-12 16:49:17 +0100254 expectedCompletions = {"example:list"};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100255 expectedContextLength = 11;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100256 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100257
Václav Kubernát51853b22019-04-16 21:53:44 +0200258 SECTION("set example:list")
259 {
260 input = "set example:list";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100261 expectedCompletions = {"example:list["};
262 expectedContextLength = 12;
Václav Kubernát4c325482019-04-11 17:51:55 +0200263 }
264
265 SECTION("cd example:list")
266 {
267 input = "cd example:list";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100268 expectedCompletions = {"example:list["};
269 expectedContextLength = 12;
Václav Kubernát51853b22019-04-16 21:53:44 +0200270 }
271
Václav Kubernát329c6c32019-02-06 16:41:53 +0100272 SECTION("cd example:list[")
273 {
274 input = "cd example:list[";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100275 expectedCompletions = {"number="};
276 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100277 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100278
Václav Kubernát329c6c32019-02-06 16:41:53 +0100279 SECTION("cd example:list[numb")
280 {
281 input = "cd example:list[numb";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100282 expectedCompletions = {"number="};
283 expectedContextLength = 4;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100284 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100285
Václav Kubernát329c6c32019-02-06 16:41:53 +0100286 SECTION("cd example:list[number")
287 {
288 input = "cd example:list[number";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100289 expectedCompletions = {"number="};
290 expectedContextLength = 6;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100291 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100292
Václav Kubernát117f7b52020-01-23 16:10:55 +0100293 SECTION("cd example:list[number=")
294 {
295 input = "cd example:list[number=";
Václav Kubernát43908fb2020-01-02 19:05:51 +0100296 expectedCompletions = {};
297 expectedContextLength = 0;
Václav Kubernát117f7b52020-01-23 16:10:55 +0100298 }
299
Václav Kubernát329c6c32019-02-06 16:41:53 +0100300 SECTION("cd example:list[number=12")
301 {
302 input = "cd example:list[number=12";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100303 expectedCompletions = {"]/"};
304 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100305 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100306
Václav Kubernát329c6c32019-02-06 16:41:53 +0100307 SECTION("cd example:list[number=12]")
308 {
309 input = "cd example:list[number=12]";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100310 expectedCompletions = {"]/"};
311 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100312 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100313
Václav Kubernát329c6c32019-02-06 16:41:53 +0100314 SECTION("cd example:twoKeyList[")
315 {
316 input = "cd example:twoKeyList[";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100317 expectedCompletions = {"name=", "number="};
318 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100319 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100320
Václav Kubernát4c325482019-04-11 17:51:55 +0200321 SECTION("cd example:twoKeyList[name=\"AHOJ\"")
322 {
323 input = "cd example:twoKeyList[name=\"AHOJ\"";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100324 expectedCompletions = {"]["};
325 expectedContextLength = 0;
Václav Kubernát4c325482019-04-11 17:51:55 +0200326 }
327
328 SECTION("cd example:twoKeyList[name=\"AHOJ\"]")
329 {
330 input = "cd example:twoKeyList[name=\"AHOJ\"]";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100331 expectedCompletions = {"]["};
332 expectedContextLength = 1;
Václav Kubernát4c325482019-04-11 17:51:55 +0200333 }
334
Václav Kubernát329c6c32019-02-06 16:41:53 +0100335 SECTION("cd example:twoKeyList[name=\"AHOJ\"][")
336 {
337 input = "cd example:twoKeyList[name=\"AHOJ\"][";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100338 expectedCompletions = {"number="};
339 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100340 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100341
Václav Kubernát329c6c32019-02-06 16:41:53 +0100342 SECTION("cd example:twoKeyList[number=42][")
343 {
344 input = "cd example:twoKeyList[number=42][";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100345 expectedCompletions = {"name="};
346 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100347 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100348
Václav Kubernát329c6c32019-02-06 16:41:53 +0100349 SECTION("cd example:twoKeyList[name=\"AHOJ\"][number=123")
350 {
351 input = "cd example:twoKeyList[name=\"AHOJ\"][number=123";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100352 expectedCompletions = {"]/"};
353 expectedContextLength = 0;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100354 }
355
356 SECTION("cd example:twoKeyList[name=\"AHOJ\"][number=123]")
357 {
358 input = "cd example:twoKeyList[name=\"AHOJ\"][number=123]";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100359 expectedCompletions = {"]/"};
360 expectedContextLength = 1;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100361 }
Václav Kubernát4c325482019-04-11 17:51:55 +0200362
363 SECTION("cd example:ovoce")
364 {
365 input = "cd example:ovoce";
Václav Kubernátcb3af402020-02-12 16:49:17 +0100366 expectedCompletions = {"example:ovoce", "example:ovocezelenina"};
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100367 expectedContextLength = 13;
Václav Kubernát4c325482019-04-11 17:51:55 +0200368 }
Václav Kubernátcb3af402020-02-12 16:49:17 +0100369
370 SECTION("cd example:ovoceze")
371 {
372 input = "cd example:ovoceze";
373 expectedCompletions = {"example:ovocezelenina"};
374 expectedContextLength = 15;
375 }
376
377 SECTION("cd example:ovocezelenina")
378 {
379 input = "cd example:ovocezelenina";
380 expectedCompletions = {"example:ovocezelenina["};
381 expectedContextLength = 21;
382 }
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100383 }
384
Václav Kubernátabf52802020-05-19 01:31:17 +0200385 SECTION("no readonly data leafs in set")
386 {
387 input = "set example:read";
388 expectedContextLength = 12;
389 }
390
Václav Kubernát8028f942019-09-25 16:03:23 +0200391 SECTION("clear completions when no longer inputting path")
392 {
393 input = "set example:leafInt ";
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100394 expectedCompletions = {};
395 expectedContextLength = 0;
Václav Kubernát8028f942019-09-25 16:03:23 +0200396 }
397
Václav Kubernátaa4250a2020-07-22 00:02:23 +0200398 SECTION("rpc input nodes NOT completed for prepare command")
Václav Kubernáte7248b22020-06-26 15:38:59 +0200399 {
Václav Kubernátaa4250a2020-07-22 00:02:23 +0200400 input = "prepare example:fire/";
Václav Kubernáte7248b22020-06-26 15:38:59 +0200401 expectedCompletions = {};
402 expectedContextLength = 13;
403 }
404
405 SECTION("rpc input nodes completed for set command")
406 {
407 parser.changeNode({{}, {{module_{"second"}, rpcNode_{"fire"}}}});
408 input = "set ";
409 expectedCompletions = {"whom "};
410 expectedContextLength = 0;
411 }
412
413 SECTION("completion for other stuff while inside an rpc")
414 {
415 parser.changeNode({{}, {{module_{"second"}, rpcNode_{"fire"}}}});
416 input = "set ../";
Václav Kubernátce108db2021-01-25 10:05:40 +0100417 expectedCompletions = {"example:addresses", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:ovocezelenina", "example:twoKeyList", "second:amelie/", "second:fire/", "example:system/", "example:system-state/"};
Václav Kubernáte7248b22020-06-26 15:38:59 +0200418 expectedContextLength = 0;
419 }
420
Václav Kubernát31029682020-10-29 08:23:04 +0100421 SECTION("rpc nodes not completed for the get command")
422 {
423 input = "get ";
Václav Kubernátce108db2021-01-25 10:05:40 +0100424 expectedCompletions = {"example:addresses", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:ovocezelenina", "example:readonly ", "example:twoKeyList", "second:amelie/", "example:system/", "example:system-state/"};
Václav Kubernát31029682020-10-29 08:23:04 +0100425 expectedContextLength = 0;
426 }
427
Václav Kubernát0d47e5e2020-11-17 12:27:05 +0100428 SECTION("leafs not completed for cd")
429 {
430 input = "cd ";
Václav Kubernátce108db2021-01-25 10:05:40 +0100431 expectedCompletions = {"example:addresses", "example:ano/", "example:anoda/", "example:bota/","example:list", "example:ovoce", "example:ovocezelenina", "example:twoKeyList", "second:amelie/", "example:system/", "example:system-state/"};
Václav Kubernát0d47e5e2020-11-17 12:27:05 +0100432 expectedContextLength = 0;
433 }
434
Václav Kubernát1ed4aa32020-01-23 13:13:28 +0100435 REQUIRE(parser.completeCommand(input, errorStream) == (Completions{expectedCompletions, expectedContextLength}));
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100436}