Add host activity and DB browser, and keep dialogs, drag-drop, and idle maintenance responsive.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
85
tests/Explorer.Application.Tests/IndexedPathPresenceTests.cs
Normal file
85
tests/Explorer.Application.Tests/IndexedPathPresenceTests.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using Explorer.Application;
|
||||
using Explorer.Domain;
|
||||
|
||||
namespace Explorer.Application.Tests;
|
||||
|
||||
public class IndexedPathPresenceTests
|
||||
{
|
||||
[Fact]
|
||||
public void Missing_tree_returns_the_highest_gone_folder()
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), "ew-idx", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(root);
|
||||
try
|
||||
{
|
||||
Assert.Equal(
|
||||
"gone",
|
||||
IndexedPathPresence.HighestMissingPrefix(root, @"gone\deep\file.txt"));
|
||||
Assert.Equal("nope.txt", IndexedPathPresence.HighestMissingPrefix(root, "nope.txt"));
|
||||
File.WriteAllText(Path.Combine(root, "keep.txt"), "x");
|
||||
Assert.Null(IndexedPathPresence.HighestMissingPrefix(root, "keep.txt"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(root, true);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Archive_inner_path_follows_the_archive_file()
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), "ew-idx", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(root);
|
||||
var zip = Path.Combine(root, "pack.zip");
|
||||
File.WriteAllBytes(zip, [1, 2, 3]);
|
||||
try
|
||||
{
|
||||
Assert.True(IndexedPathPresence.FileExists(root, @"pack.zip\inner.txt"));
|
||||
File.Delete(zip);
|
||||
Assert.False(IndexedPathPresence.FileExists(root, @"pack.zip\inner.txt"));
|
||||
Assert.Equal("pack.zip", IndexedPathPresence.HighestMissingPrefix(root, @"pack.zip\inner.txt"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Directory.Exists(root))
|
||||
{
|
||||
Directory.Delete(root, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reconcile_path_uses_the_parent_for_a_missing_file()
|
||||
{
|
||||
Assert.Equal("gone", IndexedPathPresence.ReconcilePath(@"gone\deep\file.txt", "gone"));
|
||||
Assert.Equal("", IndexedPathPresence.ReconcilePath("nope.txt", "nope.txt"));
|
||||
Assert.Equal("keep", IndexedPathPresence.ReconcilePath(@"keep\a.txt", @"keep\a.txt"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Long_paths_are_detected_with_the_extended_prefix()
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), "ew-idx", Guid.NewGuid().ToString("N"));
|
||||
var relative = Path.Combine(new string('a', 140), new string('b', 140), "file.txt");
|
||||
var full = PathRules.Combine(root, relative);
|
||||
Directory.CreateDirectory(PathRules.ToExtended(PathRules.Parent(full)));
|
||||
File.WriteAllText(PathRules.ToExtended(full), "x");
|
||||
try
|
||||
{
|
||||
Assert.True(IndexedPathPresence.FileExists(root, relative));
|
||||
File.Delete(PathRules.ToExtended(full));
|
||||
Assert.False(IndexedPathPresence.FileExists(root, relative));
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(PathRules.ToExtended(root), true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user