Replace loot_write_minimal_list_test test

Don't test what happens what happens when loot_write_minimal_list() is
given an invalid path, it turns out that's very sensitive and
non-portable. Instead test that the same error gets returned for trying
to write to a read-only file (which occurs in the same place).
This commit is contained in:
Oliver Hamlet
2016-07-21 19:50:02 +01:00
parent a02df47b0d
commit 23d1522f8b
+17 -4
View File
@@ -43,6 +43,12 @@ protected:
}
void TearDown() {
if (boost::filesystem::exists(outputPath)) {
boost::filesystem::permissions(outputPath,
boost::filesystem::perms::add_perms
| boost::filesystem::perms::owner_write);
}
ApiGameOperationsTest::TearDown();
ASSERT_NO_THROW(boost::filesystem::remove(outputPath));
@@ -87,10 +93,6 @@ TEST_P(loot_write_minimal_list_test, shouldReturnAnInvalidArgsErrorIfAPointerArg
EXPECT_EQ(loot_error_invalid_args, loot_write_minimal_list(db_, NULL, false));
}
TEST_P(loot_write_minimal_list_test, shouldReturnAFileWriteErrorIfThePathGivenIsInvalid) {
EXPECT_EQ(loot_error_file_write_fail, loot_write_minimal_list(db_, "/:?*", false));
}
TEST_P(loot_write_minimal_list_test, shouldReturnOkAndWriteToFileIfArgumentsGivenAreValid) {
EXPECT_EQ(loot_ok, loot_write_minimal_list(db_, outputPath.string().c_str(), false));
EXPECT_TRUE(boost::filesystem::exists(outputPath));
@@ -115,6 +117,17 @@ TEST_P(loot_write_minimal_list_test, shouldReturnOkIfTheFileAlreadyExistsAndTheO
EXPECT_EQ(loot_ok, loot_write_minimal_list(db_, outputPath.string().c_str(), true));
}
TEST_P(loot_write_minimal_list_test, shouldReturnAFileWriteErrorIfPathGivenExistsAndIsReadOnly) {
ASSERT_EQ(loot_ok, loot_write_minimal_list(db_, outputPath.string().c_str(), false));
ASSERT_TRUE(boost::filesystem::exists(outputPath));
boost::filesystem::permissions(outputPath,
boost::filesystem::perms::remove_perms
| boost::filesystem::perms::owner_write);
EXPECT_EQ(loot_error_file_write_fail, loot_write_minimal_list(db_, outputPath.string().c_str(), true));
}
TEST_P(loot_write_minimal_list_test, shouldWriteOnlyBashTagsAndDirtyInfo) {
ASSERT_NO_THROW(GenerateMasterlist());
ASSERT_EQ(loot_ok, loot_load_lists(db_, masterlistPath.string().c_str(), NULL));