Skip to content

Commit

Permalink
Test for $releasever_major, $releasever_minor
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-goode authored and Conan-Kudo committed Oct 11, 2023
1 parent bb1fa73 commit 1f0964f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(libdnf/conf)
add_subdirectory(libdnf/module/modulemd)
add_subdirectory(libdnf/module)
add_subdirectory(libdnf/repo)
Expand Down
33 changes: 33 additions & 0 deletions tests/libdnf/conf/ConfigParserTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "ConfigParserTest.hpp"

CPPUNIT_TEST_SUITE_REGISTRATION(ConfigParserTest);

void ConfigParserTest::setUp()
{}

void ConfigParserTest::testConfigParserReleasever()
{
{
// Test $releasever_major, $releasever_minor
std::map<std::string, std::string> substitutions = {
{"releasever", "1.23"},
};

std::string text = "major: $releasever_major, minor: $releasever_minor";
libdnf::ConfigParser::substitute(text, substitutions);
CPPUNIT_ASSERT(text == "major: 1, minor: 23");

text = "full releasever: $releasever";
libdnf::ConfigParser::substitute(text, substitutions);
CPPUNIT_ASSERT(text == "full releasever: 1.23");
}
{
// Test with empty $releasever, should set empty $releasever_major, $releasever_minor
std::map<std::string, std::string> substitutions = {
{"releasever", ""},
};
std::string text = "major: $releasever_major, minor: $releasever_minor";
libdnf::ConfigParser::substitute(text, substitutions);
CPPUNIT_ASSERT(text == "major: , minor: ");
}
}
21 changes: 21 additions & 0 deletions tests/libdnf/conf/ConfigParserTest.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef LIBDNF_CONFIGPARSERTEST_HPP
#define LIBDNF_CONFIGPARSERTEST_HPP

#include <cppunit/TestCase.h>
#include <cppunit/extensions/HelperMacros.h>

#include <libdnf/conf/ConfigParser.hpp>

class ConfigParserTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(ConfigParserTest);
CPPUNIT_TEST(testConfigParserReleasever);
CPPUNIT_TEST_SUITE_END();

public:
void setUp() override;
void testConfigParserReleasever();

};

#endif // LIBDNF_CONFIGPARSERTEST_HPP

0 comments on commit 1f0964f

Please sign in to comment.