blob: 17b7aaea43ab717c7d463ad7e6d429d2c3c97563 [file] [log] [blame]
Tomáš Peckac164ca62024-01-24 13:38:03 +01001/*
2 * Copyright (C) 2016-2019 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Jan Kundrát <jan.kundrat@cesnet.cz>
5 *
6 */
7
8#pragma once
9#include "trompeloeil_doctest.h"
10#include <map>
11#include <sysrepo-cpp/Session.hpp>
12#include <sysrepo-cpp/Connection.hpp>
13#include "test_log_setup.h"
14
Tomáš Pecka7eb64592024-01-24 14:10:47 +010015struct Deleted { };
16bool operator==(const Deleted&, const Deleted&);
17
Tomáš Peckac164ca62024-01-24 13:38:03 +010018using Values = std::map<std::string, std::string>;
Tomáš Pecka7eb64592024-01-24 14:10:47 +010019using ValueChanges = std::map<std::string, std::variant<std::string, Deleted>>;
20
21std::string nodeAsString(const libyang::DataNode& node);
Tomáš Peckac164ca62024-01-24 13:38:03 +010022
23Values dataFromSysrepo(const sysrepo::Session& session, const std::string& xpath);
24Values rpcFromSysrepo(sysrepo::Session session, const std::string& rpcPath, std::map<std::string, std::string> input);
25Values dataFromSysrepo(sysrepo::Session session, const std::string& xpath, sysrepo::Datastore datastore);
26
Tomáš Peckade062902024-01-24 13:41:16 +010027std::string moduleFromXpath(const std::string& xpath);
28
Tomáš Peckac164ca62024-01-24 13:38:03 +010029#define TEST_SYSREPO_INIT \
30 auto srConn = sysrepo::Connection{}; \
31 auto srSess = srConn.sessionStart();
32
33#define TEST_SYSREPO_INIT_CLIENT \
34 auto clientConn = sysrepo::Connection{}; \
35 auto client = clientConn.sessionStart();