Skip to content

Commit

Permalink
Added coverage for extensionless files.
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Sep 25, 2024
1 parent 18652f9 commit 29d112d
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/Foundatio.TestHarness/Storage/FileStorageTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public virtual async Task CanGetEmptyFileListOnMissingDirectoryAsync()

using (storage)
{
Assert.Empty(await storage.GetFileListAsync(Guid.NewGuid() + "\\*"));
Assert.Empty(await storage.GetFileListAsync($"{Guid.NewGuid()}\\*"));
}
}

Expand Down Expand Up @@ -283,11 +283,12 @@ public virtual async Task CanDeleteEntireFolderAsync()

using (storage)
{
await storage.SaveFileAsync(@"x\README", "hello");
await storage.SaveFileAsync(@"x\hello.txt", "hello");
await storage.SaveFileAsync(@"x\nested\world.csv", "nested world");
Assert.Equal(2, (await storage.GetFileListAsync()).Count);
Assert.Equal(3, (await storage.GetFileListAsync()).Count);

await storage.DeleteFilesAsync(@"x\*");
Assert.Equal(3, await storage.DeleteFilesAsync(@"x\*"));
Assert.Empty(await storage.GetFileListAsync());
}
}
Expand All @@ -304,13 +305,14 @@ public virtual async Task CanDeleteEntireFolderWithWildcardAsync()
{
await storage.SaveFileAsync(@"x\hello.txt", "hello");
await storage.SaveFileAsync(@"x\nested\world.csv", "nested world");
Assert.Equal(2, (await storage.GetFileListAsync()).Count);
await storage.SaveFileAsync(@"x\nested\docs\README", "manual");
Assert.Single(await storage.GetFileListAsync(limit: 1));
Assert.Equal(2, (await storage.GetFileListAsync(@"x\*")).Count);
Assert.Single(await storage.GetFileListAsync(@"x\nested\*"));

await storage.DeleteFilesAsync(@"x\*");
Assert.Equal(3, (await storage.GetFileListAsync()).Count);
Assert.Equal(3, (await storage.GetFileListAsync(@"x\*")).Count);
Assert.Equal(2, (await storage.GetFileListAsync(@"x\nested\*")).Count);
Assert.Single(await storage.GetFileListAsync(@"x\nested\docs\*"));

Assert.Equal(3, await storage.DeleteFilesAsync(@"x\*"));
Assert.Empty(await storage.GetFileListAsync());
}
}
Expand Down Expand Up @@ -388,20 +390,26 @@ public virtual async Task CanDeleteNestedFolderAsync()
using (storage)
{
await storage.SaveFileAsync(@"x\hello.txt", "hello");
await storage.SaveFileAsync(@"x\nested\world.csv", "nested world");
await storage.SaveFileAsync(@"x\nested\hello.txt", "nested hello");
Assert.Equal(3, (await storage.GetFileListAsync()).Count);
await storage.SaveFileAsync(@"x\nested\world.csv", "nested world");
await storage.SaveFileAsync(@"x\nested\docs\README", "README");
await storage.SaveFileAsync(@"x\nested\media\README", "README");
Assert.Equal(5, (await storage.GetFileListAsync()).Count);
Assert.Single(await storage.GetFileListAsync(limit: 1));
Assert.Equal(3, (await storage.GetFileListAsync(@"x\*")).Count);
Assert.Equal(2, (await storage.GetFileListAsync(@"x\nested\*")).Count);
Assert.Equal(5, (await storage.GetFileListAsync(@"x\*")).Count);
Assert.Equal(4, (await storage.GetFileListAsync(@"x\nested\*")).Count);
Assert.Equal(2, (await storage.GetFileListAsync(@"x\*.txt")).Count);

Assert.Equal(1, await storage.DeleteFilesAsync(@"x\nested\docs\"));
Assert.Equal(1, await storage.DeleteFilesAsync(@"x\nested\media"));
Assert.Equal(2, await storage.DeleteFilesAsync(@"x\nested\*"));

Assert.Single(await storage.GetFileListAsync());
Assert.True(await storage.ExistsAsync(@"x\hello.txt"));
Assert.False(await storage.ExistsAsync(@"x\nested\hello.txt"));
Assert.False(await storage.ExistsAsync(@"x\nested\world.csv"));
Assert.False(await storage.ExistsAsync(@"x\nested\docs\README"));
Assert.False(await storage.ExistsAsync(@"x\nested\media\README"));

Assert.Equal(1, await storage.DeleteFilesAsync(@"x\hello*"));
Assert.Empty(await storage.GetFileListAsync());
Expand Down Expand Up @@ -430,7 +438,7 @@ public virtual async Task CanDeleteSpecificFilesInNestedFolderAsync()
Assert.Equal(3, (await storage.GetFileListAsync(@"x\nested\*")).Count);
Assert.Equal(3, (await storage.GetFileListAsync(@"x\*.txt")).Count);

await storage.DeleteFilesAsync(@"x\nested\*.txt");
Assert.Equal(2, await storage.DeleteFilesAsync(@"x\nested\*.txt"));

Assert.Equal(3, (await storage.GetFileListAsync()).Count);
Assert.True(await storage.ExistsAsync(@"x\hello.txt"));
Expand Down

0 comments on commit 29d112d

Please sign in to comment.