FSTPersistenceTestHelpers.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #include "Firestore/core/src/firebase/firestore/util/path.h"
  18. @class FSTLevelDB;
  19. @class FSTMemoryPersistence;
  20. namespace firebase {
  21. namespace firestore {
  22. namespace local {
  23. class LruParams;
  24. } // namespace local
  25. } // namespace firestore
  26. } // namespace firebase
  27. NS_ASSUME_NONNULL_BEGIN
  28. @interface FSTPersistenceTestHelpers : NSObject
  29. /**
  30. * @return The directory where a leveldb instance can store data files. Any files that existed
  31. * there will be deleted first.
  32. */
  33. + (firebase::firestore::util::Path)levelDBDir;
  34. /**
  35. * Creates and starts a new FSTLevelDB instance for testing, destroying any previous contents
  36. * if they existed.
  37. *
  38. * Note that in order to avoid generating a bunch of garbage on the filesystem, the path of the
  39. * database is reused. This prevents concurrent running of tests using this database. We may
  40. * need to revisit this if we want to parallelize the tests.
  41. */
  42. + (FSTLevelDB *)levelDBPersistence;
  43. /**
  44. * Creates and starts a new FSTLevelDB instance for testing. Does not delete any data
  45. * present in the given directory. As a consequence, the resulting databse is not guaranteed
  46. * to be empty.
  47. */
  48. + (FSTLevelDB *)levelDBPersistenceWithDir:(firebase::firestore::util::Path)dir;
  49. /**
  50. * Creates and starts a new FSTLevelDB instance for testing, destroying any previous contents
  51. * if they existed.
  52. *
  53. * Sets up the LRU garbage collection to use the provided params.
  54. */
  55. + (FSTLevelDB *)levelDBPersistenceWithLruParams:(firebase::firestore::local::LruParams)lruParams;
  56. /** Creates and starts a new FSTMemoryPersistence instance for testing. */
  57. + (FSTMemoryPersistence *)eagerGCMemoryPersistence;
  58. + (FSTMemoryPersistence *)lruMemoryPersistence;
  59. + (FSTMemoryPersistence *)lruMemoryPersistenceWithLruParams:
  60. (firebase::firestore::local::LruParams)lruParams;
  61. @end
  62. NS_ASSUME_NONNULL_END