mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +01:00
Fix tests that broke after the changes for the removal of IonicZip.
Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
parent
2e07ff5b98
commit
68e14b1083
@ -45,12 +45,12 @@ namespace XenAdminTests.ArchiveTests
|
||||
where TR : ArchiveIterator, new()
|
||||
where TW : ArchiveWriter, new()
|
||||
{
|
||||
private string tempPath;
|
||||
private string _tempPath;
|
||||
|
||||
[SetUp]
|
||||
public void TestSetUp()
|
||||
{
|
||||
tempPath = CreateTempFolder();
|
||||
_tempPath = CreateTempFolder();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@ -58,7 +58,7 @@ namespace XenAdminTests.ArchiveTests
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(tempPath, true);
|
||||
Directory.Delete(_tempPath, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -69,7 +69,7 @@ namespace XenAdminTests.ArchiveTests
|
||||
[Test]
|
||||
public void CreateAnArchiveAndRereadWhenPossible()
|
||||
{
|
||||
string tarFileName = Path.Combine(tempPath, Path.GetRandomFileName());
|
||||
string tarFileName = Path.Combine(_tempPath, Path.GetRandomFileName());
|
||||
CheckWriteArchive(tarFileName);
|
||||
CheckReadArchive(tarFileName);
|
||||
}
|
||||
@ -86,12 +86,15 @@ namespace XenAdminTests.ArchiveTests
|
||||
reader.SetBaseStream(fs);
|
||||
while (reader.HasNext())
|
||||
{
|
||||
if (reader.IsDirectory() && expectedDirs.Contains(reader.CurrentFileName()))
|
||||
expectedDirs.Remove(reader.CurrentFileName());
|
||||
var isDirectory = reader.IsDirectory();
|
||||
var name = reader.CurrentFileName();
|
||||
|
||||
if (!reader.IsDirectory() && expectedFiles.Contains(reader.CurrentFileName()))
|
||||
if (isDirectory && expectedDirs.Contains(name))
|
||||
expectedDirs.Remove(name);
|
||||
|
||||
if (!isDirectory && expectedFiles.Contains(name))
|
||||
{
|
||||
expectedFiles.Remove(reader.CurrentFileName());
|
||||
expectedFiles.Remove(name);
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
reader.ExtractCurrentFile(ms, null);
|
||||
|
@ -133,6 +133,9 @@
|
||||
<Compile Include="XenOvf\FileDigestTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="TestResources\emptyfile.gz">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="TestResources\PluginResources\PowerShellTest.ps1">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
@ -44,6 +44,13 @@ namespace XenCenterLib.Archive
|
||||
private TarEntry tarEntry;
|
||||
private bool disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor needed by tests
|
||||
/// </summary>
|
||||
public TarArchiveIterator()
|
||||
{
|
||||
}
|
||||
|
||||
public TarArchiveIterator(Stream compressedTarFile, CompressionFactory.Type compressionType)
|
||||
{
|
||||
if (compressionType == CompressionFactory.Type.Gz)
|
||||
|
@ -45,6 +45,9 @@ namespace XenCenterLib.Archive
|
||||
private const long bufferSize = 32 * 1024;
|
||||
private bool disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor needed by tests
|
||||
/// </summary>
|
||||
public TarArchiveWriter()
|
||||
{
|
||||
}
|
||||
|
@ -50,6 +50,13 @@ namespace XenCenterLib.Archive
|
||||
/// </summary>
|
||||
public event Action<int, int> CurrentFileExtracted;
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor needed by tests
|
||||
/// </summary>
|
||||
public ZipArchiveIterator()
|
||||
{
|
||||
}
|
||||
|
||||
public ZipArchiveIterator(Stream inputStream)
|
||||
{
|
||||
_zipArchive = new ZipArchive(inputStream, ZipArchiveMode.Read);
|
||||
@ -97,8 +104,15 @@ namespace XenCenterLib.Archive
|
||||
|
||||
public override bool IsDirectory()
|
||||
{
|
||||
var attr = (FileAttributes)(_currentEntry.ExternalAttributes & 0xff);
|
||||
return attr.HasFlag(FileAttributes.Directory);
|
||||
if (_currentEntry.ExternalAttributes != 0)
|
||||
{
|
||||
var attr = (FileAttributes)(_currentEntry.ExternalAttributes & 0xff);
|
||||
return attr.HasFlag(FileAttributes.Directory);
|
||||
}
|
||||
|
||||
var name = CurrentFileName();
|
||||
return !string.IsNullOrEmpty(name) &&
|
||||
(name[name.Length - 1] == '/' || name[name.Length - 1] == '\\');
|
||||
}
|
||||
|
||||
public override void ExtractCurrentFile(Stream extractedFileContents, Action cancellingDelegate)
|
||||
|
@ -41,6 +41,13 @@ namespace XenCenterLib.Archive
|
||||
private ZipArchive _zipArchive;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor needed by tests
|
||||
/// </summary>
|
||||
public ZipArchiveWriter()
|
||||
{
|
||||
}
|
||||
|
||||
public ZipArchiveWriter(Stream outputStream)
|
||||
{
|
||||
_zipArchive = new ZipArchive(outputStream, ZipArchiveMode.Create);
|
||||
|
@ -39,6 +39,13 @@ namespace XenCenterLib.Compression
|
||||
/// </summary>
|
||||
class GZipOutputStream : CompressionStream
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameterless constructor needed by tests
|
||||
/// </summary>
|
||||
public GZipOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
public GZipOutputStream(Stream outputStream)
|
||||
{
|
||||
zipStream = new GZipStream(outputStream, CompressionMode.Compress);
|
||||
@ -55,6 +62,13 @@ namespace XenCenterLib.Compression
|
||||
/// </summary>
|
||||
class GZipInputStream : CompressionStream
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameterless constructor needed by tests
|
||||
/// </summary>
|
||||
public GZipInputStream()
|
||||
{
|
||||
}
|
||||
|
||||
public GZipInputStream(Stream inputStream)
|
||||
{
|
||||
zipStream = new GZipStream(inputStream, CompressionMode.Decompress);
|
||||
|
Loading…
Reference in New Issue
Block a user