Skip to content

Commit

Permalink
Use local temp directories
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Dec 17, 2024
1 parent 201e01c commit 5c6d19e
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace NexusMods.DataModel.SchemaVersions.Tests;

public class LegacyDatabaseSupportTests(IServiceProvider provider, TemporaryFileManager tempManager, IFileExtractor extractor)
public class LegacyDatabaseSupportTests(IServiceProvider provider, IFileExtractor extractor)
{
private readonly SignatureChecker _zipSignatureChecker = new(FileType.ZIP);

Expand All @@ -30,14 +30,20 @@ public async Task TestDatabase(string name)
var isZip = await _zipSignatureChecker.MatchesAnyAsync(stream);
isZip.Should().BeTrue("the database file should be a ZIP archive, you may need to pull the file from LFS (`git lfs pull`)");
}

await using var workingFolder = tempManager.CreateFolder();

var basePath = FileSystem.Shared.GetKnownPath(KnownPath.EntryDirectory).Combine("Temp").Combine($"Test-{Guid.NewGuid()}");
basePath.CreateDirectory();
basePath.DirectoryExists().Should().BeTrue();

using var temporaryFileManager = new TemporaryFileManager(FileSystem.Shared, basePath: basePath);

await using var workingFolder = temporaryFileManager.CreateFolder();
await extractor.ExtractAllAsync(path, workingFolder.Path);

var datamodelFolder = workingFolder.Path.Combine("MnemonicDB.rocksdb");
datamodelFolder.DirectoryExists().Should().BeTrue("the extracted database folder should exist");
datamodelFolder.EnumerateFiles().Should().NotBeEmpty("the extracted database folder should contain files");

using var backend = new Backend();
var settings = new DatomStoreSettings
{
Expand Down

0 comments on commit 5c6d19e

Please sign in to comment.