Archive.cpp (983B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #include "pch.h" 4 #include "TestCommon.h" 5 #include <winget/Archive.h> 6 7 using namespace AppInstaller::Archive; 8 using namespace TestCommon; 9 10 constexpr std::string_view s_ZipFile = "TestZip.zip"; 11 12 TEST_CASE("Extract_ZipArchive", "[archive]") 13 { 14 TestCommon::TempDirectory tempDirectory("TempDirectory"); 15 TestDataFile testZip(s_ZipFile); 16 17 const auto& testZipPath = testZip.GetPath(); 18 const auto& tempDirectoryPath = tempDirectory.GetPath(); 19 20 HRESULT hr = TryExtractArchive(testZipPath, tempDirectoryPath); 21 22 std::filesystem::path expectedPath = tempDirectoryPath / "test.txt"; 23 REQUIRE(SUCCEEDED(hr)); 24 REQUIRE(std::filesystem::exists(expectedPath)); 25 } 26 27 TEST_CASE("Scan_ZipArchive", "[archive]") 28 { 29 TestDataFile testZip(s_ZipFile); 30 31 const auto& testZipPath = testZip.GetPath(); 32 bool result = ScanZipFile(testZipPath); 33 REQUIRE(result); 34 }