FSTPersistenceTestHelpers.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "Firestore/Source/Local/FSTLRUGarbageCollector.h"
  18. #include "Firestore/core/src/firebase/firestore/util/path.h"
  19. @class FSTLevelDB;
  20. @class FSTMemoryPersistence;
  21. NS_ASSUME_NONNULL_BEGIN
  22. @interface FSTPersistenceTestHelpers : NSObject
  23. /**
  24. * @return The directory where a leveldb instance can store data files. Any files that existed
  25. * there will be deleted first.
  26. */
  27. + (firebase::firestore::util::Path)levelDBDir;
  28. /**
  29. * Creates and starts a new FSTLevelDB instance for testing, destroying any previous contents
  30. * if they existed.
  31. *
  32. * Note that in order to avoid generating a bunch of garbage on the filesystem, the path of the
  33. * database is reused. This prevents concurrent running of tests using this database. We may
  34. * need to revisit this if we want to parallelize the tests.
  35. */
  36. + (FSTLevelDB *)levelDBPersistence;
  37. /**
  38. * Creates and starts a new FSTLevelDB instance for testing. Does not delete any data
  39. * present in the given directory. As a consequence, the resulting databse is not guaranteed
  40. * to be empty.
  41. */
  42. + (FSTLevelDB *)levelDBPersistenceWithDir:(firebase::firestore::util::Path)dir;
  43. /**
  44. * Creates and starts a new FSTLevelDB instance for testing, destroying any previous contents
  45. * if they existed.
  46. *
  47. * Sets up the LRU garbage collection to use the provided params.
  48. */
  49. + (FSTLevelDB *)levelDBPersistenceWithLruParams:(firebase::firestore::local::LruParams)lruParams;
  50. /** Creates and starts a new FSTMemoryPersistence instance for testing. */
  51. + (FSTMemoryPersistence *)eagerGCMemoryPersistence;
  52. + (FSTMemoryPersistence *)lruMemoryPersistence;
  53. + (FSTMemoryPersistence *)lruMemoryPersistenceWithLruParams:
  54. (firebase::firestore::local::LruParams)lruParams;
  55. @end
  56. NS_ASSUME_NONNULL_END