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