Skip to content

Commit

Permalink
Test case to show the presence of the text vs binary bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjf committed Oct 30, 2014
1 parent 2422baf commit 0297b27
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CKAN/CKAN/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,10 @@ public static List<InstallableFile> FindInstallableFiles(CkanModule module, stri
}
}

private void CopyZipEntry(ZipFile zipfile, ZipEntry entry, string fullPath, bool makeDirs)
/// <summary>
/// Copy the entry from the opened zipfile to the path specified.
/// </summary>
internal static void CopyZipEntry(ZipFile zipfile, ZipEntry entry, string fullPath, bool makeDirs)
{
if (entry.IsDirectory)
{
Expand Down
26 changes: 26 additions & 0 deletions CKAN/Tests/CKAN/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ public void No_Installable_Files()
}
}

[Test()]
// GH #205, make sure we write in *binary*, not text.
public void BinaryNotText_205()
{
string dogezip = Tests.TestData.DogeCoinFlagZip();
ZipFile zipfile = new ZipFile(dogezip);

ZipEntry entry = zipfile.GetEntry("DogeCoinFlag-1.01/GameData/DogeCoinFlag/Flags/dogecoin.png");
string tmpfile = Path.GetTempFileName();

CKAN.ModuleInstaller.CopyZipEntry(zipfile, entry, tmpfile, false);

long size = new System.IO.FileInfo(tmpfile).Length;

try
{
// Compare recorded length against what we expect.
Assert.AreEqual(52043, size);
}
finally
{
// Tidy up.
File.Delete(tmpfile);
}
}

private void TestDogeCoinStanza(ModuleInstallDescriptor stanza)
{
Assert.AreEqual("GameData", stanza.install_to);
Expand Down

0 comments on commit 0297b27

Please sign in to comment.