Skip to content

Commit

Permalink
Added test for ensuring directories are not returned.
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Mar 13, 2024
1 parent 7a15fb7 commit 3084d5e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,38 @@ public override Task WillRespectStreamOffsetAsync()
{
return base.WillRespectStreamOffsetAsync();
}

[Fact]
public virtual async Task WillNotReturnDirectoryInGetPagedFileListAsync()
{
var storage = GetStorage();
if (storage == null)
return;

await ResetAsync(storage);

using (storage)
{
var result = await storage.GetPagedFileListAsync();
Assert.False(result.HasMore);
Assert.Empty(result.Files);
Assert.False(await result.NextPageAsync());
Assert.False(result.HasMore);
Assert.Empty(result.Files);

var client = storage is ScopedFileStorage { UnscopedStorage: SshNetFileStorage sshNetStorage }
? sshNetStorage.GetClient()
: null;
Assert.NotNull(client);

client.CreateDirectory("storage/EmptyFolder");

result = await storage.GetPagedFileListAsync();
Assert.False(result.HasMore);
Assert.Empty(result.Files);
Assert.False(await result.NextPageAsync());
Assert.False(result.HasMore);
Assert.Empty(result.Files);
}
}
}
32 changes: 32 additions & 0 deletions tests/Foundatio.Storage.SshNet.Tests/Storage/SshNetStorageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,36 @@ public override Task WillRespectStreamOffsetAsync()
{
return base.WillRespectStreamOffsetAsync();
}

[Fact]
public virtual async Task WillNotReturnDirectoryInGetPagedFileListAsync()
{
var storage = GetStorage();
if (storage == null)
return;

await ResetAsync(storage);

using (storage)
{
var result = await storage.GetPagedFileListAsync();
Assert.False(result.HasMore);
Assert.Empty(result.Files);
Assert.False(await result.NextPageAsync());
Assert.False(result.HasMore);
Assert.Empty(result.Files);

var client = storage is ScopedFileStorage { UnscopedStorage: SshNetFileStorage sshNetStorage } ? sshNetStorage.GetClient() : null;
Assert.NotNull(client);

client.CreateDirectory("storage/EmptyFolder");

result = await storage.GetPagedFileListAsync();
Assert.False(result.HasMore);
Assert.Empty(result.Files);
Assert.False(await result.NextPageAsync());
Assert.False(result.HasMore);
Assert.Empty(result.Files);
}
}
}

0 comments on commit 3084d5e

Please sign in to comment.