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

Commit

Permalink
Set result code as fake package manager failure info
Browse files Browse the repository at this point in the history
And not description, like before

Signed-off-by: Laurent Bonnans <[email protected]>
  • Loading branch information
lbonn committed Mar 21, 2019
1 parent 5c34310 commit ac922d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/libaktualizr/package_manager/packagemanagerfake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ data::InstallationResult PackageManagerFake::install(const Uptane::Target &targe
if (fiu_fail("fake_package_install") != 0) {
std::string failure_cause = fault_injection_last_info();
if (failure_cause.empty()) {
failure_cause = "Installation failed";
return data::InstallationResult(data::ResultCode::Numeric::kInstallFailed, "");
}
LOG_DEBUG << "Causing installation failure with message: " << failure_cause;
return data::InstallationResult(data::ResultCode::Numeric::kInstallFailed, failure_cause);
return data::InstallationResult(data::ResultCode(data::ResultCode::Numeric::kInstallFailed, failure_cause), "");
}

if (config.fake_need_reboot) {
Expand All @@ -46,7 +46,7 @@ data::InstallationResult PackageManagerFake::install(const Uptane::Target &targe
}

storage_->savePrimaryInstalledVersion(target, InstalledVersionUpdateMode::kCurrent);
return data::InstallationResult(data::ResultCode::Numeric::kOk, "Installing fake package was successful");
return data::InstallationResult(data::ResultCode::Numeric::kOk, "Installing package was successful");
}

void PackageManagerFake::completeInstall() const {
Expand Down
5 changes: 2 additions & 3 deletions src/libaktualizr/package_manager/packagemanagerfake_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ TEST(PackageManagerFake, FailureInjection) {
fault_injection_disable("fake_package_install");

// fault with custom data (through pid file)
fault_injection_enable("fake_package_install", 1, "Random cause", 0);
fault_injection_enable("fake_package_install", 1, "RANDOM_CAUSE", 0);
result = fakepm.install(target);
EXPECT_EQ(result.result_code, data::ResultCode::Numeric::kInstallFailed);
EXPECT_EQ(result.description, "Random cause");
EXPECT_EQ(result.result_code, data::ResultCode(data::ResultCode::Numeric::kInstallFailed, "RANDOM_CAUSE"));
fault_injection_disable("fake_package_install");
}

Expand Down

0 comments on commit ac922d0

Please sign in to comment.