Skip to content

[Question] Best Way To Modify Firebase's storage directory for testing #1507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brianmichel opened this issue Jan 5, 2024 · 2 comments
Closed

Comments

@brianmichel
Copy link

[REQUIRED] Please fill in the following fields:

  • Pre-built SDK from the website or open-source from this repo: open-source
  • Firebase C++ SDK version: 11.3.0
  • Main Firebase Components in concern: App
  • Other Firebase Components in use: Auth, Firestore
  • Platform you are using the C++ SDK on: Windows
  • Platform you are targeting: Desktop

[REQUIRED] Please describe the question here:

On macOS it's possible to override the application support directory as part of your testing suite, which in turn modifies where firebase files get stored. On Windows it looks like the SDK is using the known folder apis (

HRESULT hr = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &path);
) which is problematic when we're trying to do automated integration testing since we'd ideally like to override this folder to provide a clean slate for each test and it seems like that this machinery prevents that.

Do you have any advice on how to work around this, or if there is some other way to change the parent directory here in the testing scenario.

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@dconeybe
Copy link
Contributor

dconeybe commented Jan 8, 2024

Hi @brianmichel. At the moment there is no way to configure the directory into which Firestore writes its information. I've opened up an internal feature request ticket for this request though (b/319104045). I have to be honest, though, that the likelihood of it getting implemented is low due to competing team priorities.

As you discovered, Firestore on Windows uses a subdirectory of the user's "LocalAppData" directory. On macOS it uses a subdirectory of NSApplicationSupportDirectory. If you'd like to see the low-level details, the function LevelDbOpener::FirestoreAppDataDir() is where the decision is actually made (link). It uses a utility class called "FileSystem" with a Windows implementation, macOS/iOS implementation, and Linux implementation. If you turn on Firestore debug logging, the logs will include the full directory used.

For your specific use case, you could manually delete this directory in between tests. Alternately, you could call Firestore.clearPersistence() before running each test. This isn't quite the same as an empty directory but it's pretty close.

@dconeybe dconeybe closed this as completed Jan 8, 2024
@firebase firebase locked and limited conversation to collaborators Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants