Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
packagemanage: Fix output of pacman config
Browse files Browse the repository at this point in the history
When the config is dumped out for the docker-app manager, the custom
config key/vals are printed val=key. eg:

 "/tmp/sota/docker-apps" = docker_apps_root

This fixes the issue.

Signed-off-by: Andy Doan <[email protected]>
  • Loading branch information
doanac committed Sep 25, 2020
1 parent 5336fd2 commit d9abc9f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/libaktualizr/package_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ if(BUILD_OSTREE)
endif(BUILD_DOCKERAPP)
endif(BUILD_OSTREE)

add_aktualizr_test(NAME packagemanagerconfig SOURCES packagemanagerconfig_test.cc NO_VALGRIND)
add_aktualizr_test(NAME packagemanager_factory SOURCES packagemanagerfactory_test.cc
ARGS ${PROJECT_BINARY_DIR}/ostree_repo)
add_aktualizr_test(NAME fetcher SOURCES fetcher_test.cc ARGS PROJECT_WORKING_DIRECTORY LIBRARIES PUBLIC uptane_generator_lib)
add_aktualizr_test(NAME fetcher_death SOURCES fetcher_death_test.cc NO_VALGRIND ARGS PROJECT_WORKING_DIRECTORY)

aktualizr_source_file_checks(fetcher_death_test.cc fetcher_test.cc)

aktualizr_source_file_checks(packagemanagerconfig_test.cc)

aktualizr_source_file_checks(packagemanagerfake_test.cc packagemanagerfactory_test.cc ostreemanager_test.cc)

aktualizr_source_file_checks(ostreemanager.cc ostreemanager.h)
Expand Down
2 changes: 1 addition & 1 deletion src/libaktualizr/package_manager/packagemanagerconfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ void PackageConfig::writeToStream(std::ostream& out_stream) const {
// note that this is imperfect as it will not print default values deduced
// from users of `extra`
for (const auto& e : extra) {
writeOption(out_stream, e.first, e.second);
writeOption(out_stream, e.second, e.first);
}
}
25 changes: 25 additions & 0 deletions src/libaktualizr/package_manager/packagemanagerconfig_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <gtest/gtest.h>

#include "libaktualizr/config.h"
#include "logging/logging.h"

TEST(PackageManagerConfig, WriteToStream) {
PackageConfig config;
config.os = "amiga";
config.fake_need_reboot = true;
config.extra["foo"] = "bar";
std::stringstream out;
config.writeToStream(out);
std::string cfg = out.str();

ASSERT_NE(std::string::npos, cfg.find("os = \"amiga\""));
ASSERT_NE(std::string::npos, cfg.find("fake_need_reboot = 1"));
ASSERT_NE(std::string::npos, cfg.find("foo = \"bar\""));
}

#ifndef __NO_MAIN__
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
#endif

0 comments on commit d9abc9f

Please sign in to comment.