Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 9 | #include "trompeloeil_catch.h" |
| 10 | |
| 11 | #include "sysrepo_access.hpp" |
| 12 | #include "sysrepo_subscription.hpp" |
| 13 | #include "sysrepo_vars.hpp" |
| 14 | |
| 15 | class MockRecorder : public Recorder |
| 16 | { |
| 17 | public: |
| 18 | MAKE_MOCK3(write, void(const std::string&, const std::string&, const std::string&), override); |
| 19 | }; |
| 20 | |
| 21 | TEST_CASE("setting values") |
| 22 | { |
| 23 | if (system(SYSREPOCTLEXECUTABLE " --uninstall --module example-schema > /dev/null") != 0) { |
| 24 | // uninstall can fail if it isn't already installed -> do nothing |
| 25 | // This crappy comment is here due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509 |
| 26 | } |
| 27 | REQUIRE(system(SYSREPOCTLEXECUTABLE " --install --yang " EXAMPLE_SCHEMA_LOCATION " > /dev/null") == 0); |
| 28 | |
| 29 | trompeloeil::sequence seq1; |
| 30 | MockRecorder mock; |
| 31 | SysrepoSubscription subscription(&mock); |
| 32 | SysrepoAccess datastore("netconf-cli-test"); |
| 33 | |
| 34 | SECTION("set leafInt to 123") |
| 35 | { |
| 36 | REQUIRE_CALL(mock, write("/example-schema:leafInt", "", "123")); |
| 37 | datastore.setLeaf("/example-schema:leafInt", 123); |
| 38 | datastore.commitChanges(); |
| 39 | } |
| 40 | |
| 41 | SECTION("set leafEnum to coze") |
| 42 | { |
| 43 | REQUIRE_CALL(mock, write("/example-schema:leafEnum", "", "coze")); |
| 44 | datastore.setLeaf("/example-schema:leafEnum", enum_{"coze"}); |
| 45 | datastore.commitChanges(); |
| 46 | } |
| 47 | |
| 48 | SECTION("set leafDecimal to 123.544") |
| 49 | { |
| 50 | REQUIRE_CALL(mock, write("/example-schema:leafDecimal", "", "123.544")); |
| 51 | datastore.setLeaf("/example-schema:leafDecimal", 123.544); |
| 52 | datastore.commitChanges(); |
| 53 | } |
| 54 | |
| 55 | SECTION("create presence container") |
| 56 | { |
| 57 | REQUIRE_CALL(mock, write("/example-schema:pContainer", "", "")); |
| 58 | datastore.createPresenceContainer("/example-schema:pContainer"); |
| 59 | datastore.commitChanges(); |
| 60 | } |
| 61 | |
| 62 | waitForCompletionAndBitMore(seq1); |
| 63 | } |