Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: client/crash_report_database_test.cc

Issue 1392653002: Add functionality to prune old crash reports from the database. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/crash_report_database_test.cc
diff --git a/client/crash_report_database_test.cc b/client/crash_report_database_test.cc
index 6a04d19cfa802cd8a162c48b2aab8832c115f2b8..22062f8992ece968337fdcd733f8b4daf5965770 100644
--- a/client/crash_report_database_test.cc
+++ b/client/crash_report_database_test.cc
@@ -526,6 +526,50 @@ TEST_F(CrashReportDatabaseTest, ReportRemoved) {
db()->LookUpCrashReport(uuid, &report));
}
+TEST_F(CrashReportDatabaseTest, DeleteReport) {
+ CrashReportDatabase::Report keep_pending;
+ CrashReportDatabase::Report delete_pending;
+ CrashReportDatabase::Report keep_completed;
+ CrashReportDatabase::Report delete_completed;
+
+ CreateCrashReport(&keep_pending);
+ CreateCrashReport(&delete_pending);
+ CreateCrashReport(&keep_completed);
+ CreateCrashReport(&delete_completed);
+
+ EXPECT_TRUE(FileExistsAtPath(keep_pending.file_path));
Mark Mentovai 2015/10/07 03:54:27 FileExistsAtPath() is going away in https://codere
Robert Sesek 2015/10/07 16:24:34 Done.
+ EXPECT_TRUE(FileExistsAtPath(delete_pending.file_path));
+ EXPECT_TRUE(FileExistsAtPath(keep_completed.file_path));
+ EXPECT_TRUE(FileExistsAtPath(delete_completed.file_path));
+
+ UploadReport(keep_completed.uuid, true, "1");
+ UploadReport(delete_completed.uuid, true, "2");
+
+ EXPECT_EQ(CrashReportDatabase::kNoError,
+ db()->LookUpCrashReport(keep_completed.uuid, &keep_completed));
+ EXPECT_EQ(CrashReportDatabase::kNoError,
+ db()->LookUpCrashReport(delete_completed.uuid, &delete_completed));
+
+ EXPECT_TRUE(FileExistsAtPath(keep_completed.file_path));
+ EXPECT_TRUE(FileExistsAtPath(delete_completed.file_path));
+
+ EXPECT_EQ(CrashReportDatabase::kNoError,
+ db()->DeleteReport(delete_pending.uuid));
+ EXPECT_FALSE(FileExistsAtPath(delete_pending.file_path));
+ EXPECT_EQ(CrashReportDatabase::kReportNotFound,
+ db()->LookUpCrashReport(delete_pending.uuid, &delete_pending));
+ EXPECT_EQ(CrashReportDatabase::kReportNotFound,
+ db()->DeleteReport(delete_pending.uuid));
+
+ EXPECT_EQ(CrashReportDatabase::kNoError,
+ db()->DeleteReport(delete_completed.uuid));
+ EXPECT_FALSE(FileExistsAtPath(delete_completed.file_path));
+ EXPECT_EQ(CrashReportDatabase::kReportNotFound,
+ db()->LookUpCrashReport(delete_completed.uuid, &delete_completed));
+ EXPECT_EQ(CrashReportDatabase::kReportNotFound,
+ db()->DeleteReport(delete_completed.uuid));
+}
Mark Mentovai 2015/10/07 03:54:27 Make sure the deletes didn’t delete beyond their s
Robert Sesek 2015/10/07 16:24:34 Done.
+
} // namespace
} // namespace test
} // namespace crashpad

Powered by Google App Engine
This is Rietveld 408576698