// Deletes files that are no longer reachable via our storage system's// metadata.class FileCleaner {public: class Env { public: virtual bool MatchFiles(const char* pattern, vector* filenames) = 0; virtual bool BulkDelete(const vector& filenames) = 0; virtual MetadataReader* NewMetadataReader() = 0; virtual ~Env(); }; // Constructs a FileCleaner. Uses “env” to access files and metadata. FileCleaner(Env* env, QuotaManager* qm); // Deletes files that are not reachable via metadata. // Returns true on success. bool CleanOnce();};
class NoFileSystemEnv : public FileCleaner::Env { virtual bool MatchFiles(const char* pattern, vector* filenames) { match_files_called_ = true; return false; } ...};TEST(FileCleanerTest, FileCleaningFailsWhenFileSystemFails) { NoFileSystemEnv* env = new NoFileSystemEnv(); FileCleaner cleaner(env, new MockQuotaManager()); ASSERT_FALSE(cleaner.CleanOnce()); ASSERT_TRUE(env->match_files_called_);}
The comments you read and contribute here belong only to the person who posted them. We reserve the right to remove off-topic comments.
No comments :
Post a Comment
The comments you read and contribute here belong only to the person who posted them. We reserve the right to remove off-topic comments.