Skip to content

Commit

Permalink
Add include folder interface to the FileSystemCallbacks constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Willford committed Aug 5, 2019
1 parent f3527b6 commit 7b52897
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 32 deletions.
1 change: 1 addition & 0 deletions GVFS/GVFS.Mount/InProcessMount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ private void MountAndStartWorkingDirectoryCallbacks(CacheServerInfo cache)
backgroundFileSystemTaskRunner: null,
fileSystemVirtualizer: virtualizer,
placeholderDatabase: new PlaceholderTable(this.gvfsDatabase),
includedFolderCollection: new IncludedFolderTable(this.gvfsDatabase),
gitStatusCache: gitStatusCache);
}, "Failed to create src folder callback listener");
this.maintenanceScheduler = this.CreateOrReportAndExit(() => new GitMaintenanceScheduler(this.context, this.gitObjects), "Failed to start maintenance scheduler");
Expand Down
1 change: 1 addition & 0 deletions GVFS/GVFS.PerfProfiling/ProfilingEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private FileSystemCallbacks CreateFileSystemCallbacks()
backgroundFileSystemTaskRunner: null,
fileSystemVirtualizer: null,
placeholderDatabase: new PlaceholderTable(this.gvfsDatabase),
includedFolderCollection: new IncludedFolderTable(this.gvfsDatabase),
gitStatusCache : null);
}
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public MockFileSystemCallbacks(
GitIndexProjection gitIndexProjection,
BackgroundFileSystemTaskRunner backgroundFileSystemTaskRunner,
FileSystemVirtualizer fileSystemVirtualizer,
IPlaceholderCollection placeholderDatabase)
: base(context, gitObjects, repoMetadata, blobSizes, gitIndexProjection, backgroundFileSystemTaskRunner, fileSystemVirtualizer, placeholderDatabase)
IPlaceholderCollection placeholderDatabase,
IIncludedFolderCollection includedFolderCollection)
: base(context, gitObjects, repoMetadata, blobSizes, gitIndexProjection, backgroundFileSystemTaskRunner, fileSystemVirtualizer, placeholderDatabase, includedFolderCollection)
{
}

Expand Down
40 changes: 32 additions & 8 deletions GVFS/GVFS.UnitTests/Platform.Mac/MacFileSystemVirtualizerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void UpdatePlaceholderIfNeeded()
const string UpdatePlaceholderFileName = "testUpdatePlaceholder.txt";
Mock<IPlaceholderCollection> mockPlaceholderDb = new Mock<IPlaceholderCollection>(MockBehavior.Strict);
mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1);
Mock<IIncludedFolderCollection> mockIncludeDb = new Mock<IIncludedFolderCollection>(MockBehavior.Strict);
using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner())
using (MockVirtualizationInstance mockVirtualization = new MockVirtualizationInstance())
using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { UpdatePlaceholderFileName }))
Expand All @@ -102,7 +103,8 @@ public void UpdatePlaceholderIfNeeded()
gitIndexProjection,
backgroundTaskRunner,
virtualizer,
mockPlaceholderDb.Object))
mockPlaceholderDb.Object,
mockIncludeDb.Object))
{
gitIndexProjection.MockFileTypesAndModes.TryAdd(
UpdatePlaceholderFileName,
Expand Down Expand Up @@ -172,6 +174,7 @@ public void UpdatePlaceholderIfNeeded()
}

mockPlaceholderDb.VerifyAll();
mockIncludeDb.VerifyAll();
}

[TestCase]
Expand All @@ -180,6 +183,7 @@ public void WritePlaceholderForSymLink()
const string WriteSymLinkFileName = "testWriteSymLink.txt";
Mock<IPlaceholderCollection> mockPlaceholderDb = new Mock<IPlaceholderCollection>(MockBehavior.Strict);
mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1);
Mock<IIncludedFolderCollection> mockIncludeDb = new Mock<IIncludedFolderCollection>(MockBehavior.Strict);
using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner())
using (MockVirtualizationInstance mockVirtualization = new MockVirtualizationInstance())
using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { WriteSymLinkFileName }))
Expand All @@ -192,7 +196,8 @@ public void WritePlaceholderForSymLink()
gitIndexProjection,
backgroundTaskRunner,
virtualizer,
mockPlaceholderDb.Object))
mockPlaceholderDb.Object,
mockIncludeDb.Object))
{
gitIndexProjection.MockFileTypesAndModes.TryAdd(
WriteSymLinkFileName,
Expand All @@ -219,6 +224,7 @@ public void WritePlaceholderForSymLink()
}

mockPlaceholderDb.VerifyAll();
mockIncludeDb.VerifyAll();
}

[TestCase]
Expand All @@ -227,6 +233,7 @@ public void UpdatePlaceholderToSymLink()
const string PlaceholderToLinkFileName = "testUpdatePlaceholderToLink.txt";
Mock<IPlaceholderCollection> mockPlaceholderDb = new Mock<IPlaceholderCollection>(MockBehavior.Strict);
mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1);
Mock<IIncludedFolderCollection> mockIncludeDb = new Mock<IIncludedFolderCollection>(MockBehavior.Strict);
using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner())
using (MockVirtualizationInstance mockVirtualization = new MockVirtualizationInstance())
using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { PlaceholderToLinkFileName }))
Expand All @@ -239,7 +246,8 @@ public void UpdatePlaceholderToSymLink()
gitIndexProjection,
backgroundTaskRunner,
virtualizer,
mockPlaceholderDb.Object))
mockPlaceholderDb.Object,
mockIncludeDb.Object))
{
gitIndexProjection.MockFileTypesAndModes.TryAdd(
PlaceholderToLinkFileName,
Expand Down Expand Up @@ -279,6 +287,7 @@ public void UpdatePlaceholderToSymLink()
}

mockPlaceholderDb.VerifyAll();
mockIncludeDb.VerifyAll();
}

[TestCase]
Expand All @@ -301,6 +310,7 @@ public void OnEnumerateDirectoryReturnsSuccessWhenResultsNotInMemory()
string testFilePath = Path.Combine(TestFolderName, TestFileName);
Mock<IPlaceholderCollection> mockPlaceholderDb = new Mock<IPlaceholderCollection>(MockBehavior.Strict);
mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1);
Mock<IIncludedFolderCollection> mockIncludeDb = new Mock<IIncludedFolderCollection>(MockBehavior.Strict);
using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner())
using (MockVirtualizationInstance mockVirtualization = new MockVirtualizationInstance())

Expand All @@ -316,7 +326,8 @@ public void OnEnumerateDirectoryReturnsSuccessWhenResultsNotInMemory()
gitIndexProjection,
backgroundTaskRunner,
virtualizer,
mockPlaceholderDb.Object))
mockPlaceholderDb.Object,
mockIncludeDb.Object))
{
gitIndexProjection.MockFileTypesAndModes.TryAdd(
testFilePath,
Expand All @@ -334,6 +345,7 @@ public void OnEnumerateDirectoryReturnsSuccessWhenResultsNotInMemory()
}

mockPlaceholderDb.VerifyAll();
mockIncludeDb.VerifyAll();
}

[TestCase]
Expand All @@ -344,6 +356,7 @@ public void OnEnumerateDirectoryReturnsSuccessWhenResultsInMemory()
string testFilePath = Path.Combine(TestFolderName, TestFileName);
Mock<IPlaceholderCollection> mockPlaceholderDb = new Mock<IPlaceholderCollection>(MockBehavior.Strict);
mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1);
Mock<IIncludedFolderCollection> mockIncludeDb = new Mock<IIncludedFolderCollection>(MockBehavior.Strict);
using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner())
using (MockVirtualizationInstance mockVirtualization = new MockVirtualizationInstance())

Expand All @@ -359,7 +372,8 @@ public void OnEnumerateDirectoryReturnsSuccessWhenResultsInMemory()
gitIndexProjection,
backgroundTaskRunner,
virtualizer,
mockPlaceholderDb.Object))
mockPlaceholderDb.Object,
mockIncludeDb.Object))
{
gitIndexProjection.MockFileTypesAndModes.TryAdd(
testFilePath,
Expand All @@ -378,6 +392,7 @@ public void OnEnumerateDirectoryReturnsSuccessWhenResultsInMemory()
}

mockPlaceholderDb.VerifyAll();
mockIncludeDb.VerifyAll();
}

[TestCase]
Expand All @@ -392,6 +407,7 @@ public void OnEnumerateDirectorySetsFileModes()
string testFile755Path = Path.Combine(TestFolderName, TestFile755Name);
Mock<IPlaceholderCollection> mockPlaceholderDb = new Mock<IPlaceholderCollection>(MockBehavior.Strict);
mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1);
Mock<IIncludedFolderCollection> mockIncludeDb = new Mock<IIncludedFolderCollection>(MockBehavior.Strict);
using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner())
using (MockVirtualizationInstance mockVirtualization = new MockVirtualizationInstance())

Expand All @@ -407,7 +423,8 @@ public void OnEnumerateDirectorySetsFileModes()
gitIndexProjection,
backgroundTaskRunner,
virtualizer,
mockPlaceholderDb.Object))
mockPlaceholderDb.Object,
mockIncludeDb.Object))
{
gitIndexProjection.MockFileTypesAndModes.TryAdd(
testFile644Path,
Expand Down Expand Up @@ -435,6 +452,7 @@ public void OnEnumerateDirectorySetsFileModes()
}

mockPlaceholderDb.VerifyAll();
mockIncludeDb.VerifyAll();
}

[TestCase]
Expand All @@ -443,6 +461,7 @@ public void OnGetFileStreamReturnsSuccessWhenFileStreamAvailable()
const string TestFileName = "test.txt";
Mock<IPlaceholderCollection> mockPlaceholderDb = new Mock<IPlaceholderCollection>(MockBehavior.Strict);
mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1);
Mock<IIncludedFolderCollection> mockIncludeDb = new Mock<IIncludedFolderCollection>(MockBehavior.Strict);
using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner())
using (MockVirtualizationInstance mockVirtualization = new MockVirtualizationInstance())
using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { TestFileName }))
Expand All @@ -455,7 +474,8 @@ public void OnGetFileStreamReturnsSuccessWhenFileStreamAvailable()
gitIndexProjection,
backgroundTaskRunner,
virtualizer,
mockPlaceholderDb.Object))
mockPlaceholderDb.Object,
mockIncludeDb.Object))
{
string error;
fileSystemCallbacks.TryStart(out error).ShouldEqual(true);
Expand Down Expand Up @@ -483,6 +503,7 @@ public void OnGetFileStreamReturnsSuccessWhenFileStreamAvailable()
}

mockPlaceholderDb.VerifyAll();
mockIncludeDb.VerifyAll();
}

[TestCase]
Expand All @@ -492,6 +513,7 @@ public void OnGetFileStreamReturnsErrorWhenWriteFileContentsFails()
const string TestFileName = "test.txt";
Mock<IPlaceholderCollection> mockPlaceholderDb = new Mock<IPlaceholderCollection>(MockBehavior.Strict);
mockPlaceholderDb.Setup(x => x.GetCount()).Returns(1);
Mock<IIncludedFolderCollection> mockIncludeDb = new Mock<IIncludedFolderCollection>(MockBehavior.Strict);
using (MockBackgroundFileSystemTaskRunner backgroundTaskRunner = new MockBackgroundFileSystemTaskRunner())
using (MockVirtualizationInstance mockVirtualization = new MockVirtualizationInstance())
using (MockGitIndexProjection gitIndexProjection = new MockGitIndexProjection(new[] { TestFileName }))
Expand All @@ -504,7 +526,8 @@ public void OnGetFileStreamReturnsErrorWhenWriteFileContentsFails()
gitIndexProjection,
backgroundTaskRunner,
virtualizer,
mockPlaceholderDb.Object))
mockPlaceholderDb.Object,
mockIncludeDb.Object))
{
string error;
fileSystemCallbacks.TryStart(out error).ShouldEqual(true);
Expand All @@ -530,6 +553,7 @@ public void OnGetFileStreamReturnsErrorWhenWriteFileContentsFails()
}

mockPlaceholderDb.VerifyAll();
mockIncludeDb.VerifyAll();
}

private static ushort ConvertFileTypeAndModeToIndexFormat(GitIndexProjection.FileType fileType, ushort fileMode)
Expand Down
Loading

0 comments on commit 7b52897

Please sign in to comment.