aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/downloader/zip_downloader_test.rs
blob: 0bffa89aa834cb3d43a2fe77a84975de958c6373 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//! ref: composer/tests/Composer/Test/Downloader/ZipDownloaderTest.php

use shirabe::util::filesystem::Filesystem;
use tempfile::TempDir;

struct SetUp {
    test_dir: TempDir,
    filename: std::path::PathBuf,
}

fn set_up() -> SetUp {
    let test_dir = TempDir::new().unwrap();
    // The IO/Config/HttpDownloader/Package mocks are not ported; HttpDownloader construction
    // additionally reaches curl_multi_init (todo!()).
    let () = todo!();
    #[allow(unreachable_code)]
    {
        let filename = test_dir.path().join("composer-test.zip");
        std::fs::write(&filename, "zip").unwrap();
        SetUp { test_dir, filename }
    }
}

fn tear_down(test_dir: &std::path::Path) {
    let mut fs = Filesystem::new(None);
    fs.remove_directory(test_dir).unwrap();
    // setPrivateProperty('hasZipArchive', null) resets a ZipDownloader static via reflection;
    // the static is not reachable from a test here.
    todo!()
}

struct TearDown {
    test_dir: std::path::PathBuf,
}

impl TearDown {
    fn new(test_dir: std::path::PathBuf) -> Self {
        TearDown { test_dir }
    }
}

impl Drop for TearDown {
    fn drop(&mut self) {
        tear_down(&self.test_dir);
    }
}

// These construct a ZipDownloader with a mocked IO/HttpDownloader/ProcessExecutor and rely
// on ZipArchive extraction (todo!() in the php-shim) plus mocked unzip behaviour.
#[ignore = "requires PHPUnit mocks of IOInterface/Config/PackageInterface; set_up() is todo!() and real HttpDownloader reaches curl_multi_init todo!(); no mocking framework"]
#[test]
fn test_error_messages() {
    let set_up = set_up();
    let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf());
    let _ = (&set_up.test_dir, &set_up.filename);
    todo!()
}

#[ignore = "requires setPrivateProperty reflection on hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and a getMockBuilder('ZipArchive') mock; no mocking/reflection framework"]
#[test]
fn test_zip_archive_only_failed() {
    let set_up = set_up();
    let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf());
    let _ = (&set_up.test_dir, &set_up.filename);
    todo!()
}

#[ignore = "requires setPrivateProperty reflection on hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and a getMockBuilder('ZipArchive') mock throwing ErrorException; no mocking/reflection framework"]
#[test]
fn test_zip_archive_extract_only_failed() {
    let set_up = set_up();
    let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf());
    let _ = (&set_up.test_dir, &set_up.filename);
    todo!()
}

#[ignore = "requires setPrivateProperty reflection on hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and a getMockBuilder('ZipArchive') mock; no mocking/reflection framework"]
#[test]
fn test_zip_archive_only_good() {
    let set_up = set_up();
    let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf());
    let _ = (&set_up.test_dir, &set_up.filename);
    todo!()
}

#[ignore = "requires setPrivateProperty reflection on isWindows/hasZipArchive/unzipCommands, a MockedZipDownloader subclass, and getMockBuilder mocks of Process/ProcessExecutor::executeAsync; no mocking/reflection framework"]
#[test]
fn test_system_unzip_only_failed() {
    let set_up = set_up();
    let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf());
    let _ = (&set_up.test_dir, &set_up.filename);
    todo!()
}

#[ignore = "requires setPrivateProperty reflection on isWindows/hasZipArchive/unzipCommands, a MockedZipDownloader subclass, and getMockBuilder mocks of Process/ProcessExecutor::executeAsync; no mocking/reflection framework"]
#[test]
fn test_system_unzip_only_good() {
    let set_up = set_up();
    let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf());
    let _ = (&set_up.test_dir, &set_up.filename);
    todo!()
}

#[ignore = "requires setPrivateProperty reflection on isWindows/hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and getMockBuilder mocks of Process/ProcessExecutor/ZipArchive; no mocking/reflection framework"]
#[test]
fn test_non_windows_fallback_good() {
    let set_up = set_up();
    let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf());
    let _ = (&set_up.test_dir, &set_up.filename);
    todo!()
}

#[ignore = "requires setPrivateProperty reflection on isWindows/hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and getMockBuilder mocks of Process/ProcessExecutor/ZipArchive; no mocking/reflection framework"]
#[test]
fn test_non_windows_fallback_failed() {
    let set_up = set_up();
    let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf());
    let _ = (&set_up.test_dir, &set_up.filename);
    todo!()
}