FSTPersistenceTestHelpers.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. NS_ASSUME_NONNULL_BEGIN
  21. @interface FSTPersistenceTestHelpers : NSObject
  22. /**
  23. * @return The directory where a leveldb instance can store data files. Any files that existed
  24. * there will be deleted first.
  25. */
  26. + (firebase::firestore::util::Path)levelDBDir;
  27. /**
  28. * Creates and starts a new FSTLevelDB instance for testing, destroying any previous contents
  29. * if they existed.
  30. *
  31. * Note that in order to avoid generating a bunch of garbage on the filesystem, the path of the
  32. * database is reused. This prevents concurrent running of tests using this database. We may
  33. * need to revisit this if we want to parallelize the tests.
  34. */
  35. + (FSTLevelDB *)levelDBPersistence;
  36. /**
  37. * Creates and starts a new FSTLevelDB instance for testing. Does not delete any data
  38. * present in the given directory. As a consequence, the resulting databse is not guaranteed
  39. * to be empty.
  40. */
  41. + (FSTLevelDB *)levelDBPersistenceWithDir:(firebase::firestore::util::Path)dir;
  42. /** Creates and starts a new FSTMemoryPersistence instance for testing. */
  43. + (FSTMemoryPersistence *)eagerGCMemoryPersistence;
  44. + (FSTMemoryPersistence *)lruMemoryPersistence;
  45. @end
  46. NS_ASSUME_NONNULL_END