blob: 2405b4bd498f344d6b24583a21d601b181a00cd2 (
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
//! ref: composer/tests/Composer/Test/Downloader/DownloadManagerTest.php
use std::cell::RefCell;
use std::rc::Rc;
use shirabe::downloader::DownloaderInterface;
use shirabe::downloader::download_manager::DownloadManager;
use shirabe::io::IOInterface;
use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle};
use shirabe_semver::VersionParser;
use crate::downloader_stub::DownloaderStub;
use crate::io_stub::IOStub;
/// ref: DownloadManagerTest::createPackageMock
///
/// PHPUnit returns a `PackageInterface` mock; a real CompletePackage with the
/// relevant fields left at their defaults is an equivalent stand-in for the
/// installation-source/type dispatch logic exercised by the ported cases.
fn create_package_mock() -> PackageInterfaceHandle {
let norm_version = VersionParser.normalize("1.0.0", None).unwrap();
CompletePackageHandle::new("dummy/pkg".to_string(), norm_version, "1.0.0".to_string()).into()
}
/// ref: DownloadManagerTest::createDownloaderMock
fn create_downloader_mock() -> Rc<RefCell<dyn DownloaderInterface>> {
Rc::new(RefCell::new(DownloaderStub::new())) as Rc<RefCell<dyn DownloaderInterface>>
}
fn create_manager() -> DownloadManager {
let io = Rc::new(RefCell::new(IOStub::new())) as Rc<RefCell<dyn IOInterface>>;
DownloadManager::new(io, false, None)
}
#[test]
fn test_set_get_downloader() {
let downloader = create_downloader_mock();
let mut manager = create_manager();
manager.set_downloader("test", downloader.clone());
assert!(Rc::ptr_eq(
&downloader,
&manager.get_downloader("test").unwrap()
));
let result = manager.get_downloader("unregistered");
assert!(result.is_err());
}
#[test]
fn test_get_downloader_for_incorrectly_installed_package() {
// getInstallationSource() => null (the default for a fresh package).
let package = create_package_mock();
let manager = create_manager();
let result = manager.get_downloader_for_package(package);
assert!(result.is_err());
}
#[test]
fn test_get_downloader_for_metapackage() {
let package = create_package_mock();
package.__set_type("metapackage".to_string());
let manager = create_manager();
assert!(
manager
.get_downloader_for_package(package)
.unwrap()
.is_none()
);
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloader"]
#[test]
fn test_get_downloader_for_correctly_installed_dist_package() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloader"]
#[test]
fn test_get_downloader_for_incorrectly_installed_dist_package() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloader"]
#[test]
fn test_get_downloader_for_correctly_installed_source_package() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloader"]
#[test]
fn test_get_downloader_for_incorrectly_installed_source_package() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_full_package_download() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_full_package_download_failover() {
todo!()
}
#[ignore = "requires PHPUnit mock of PackageInterface (createPackageMock)"]
#[test]
fn test_bad_package_download() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_dist_only_package_download() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_source_only_package_download() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_metapackage_package_download() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_full_package_download_with_source_preferred() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_dist_only_package_download_with_source_preferred() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_source_only_package_download_with_source_preferred() {
todo!()
}
#[ignore = "requires PHPUnit mock of PackageInterface (createPackageMock)"]
#[test]
fn test_bad_package_download_with_source_preferred() {
todo!()
}
#[ignore = "requires PHPUnit mocks of PackageInterface and DownloaderInterface"]
#[test]
fn test_update_dist_with_equal_types() {
todo!()
}
#[ignore = "requires PHPUnit mocks of PackageInterface and DownloaderInterface"]
#[test]
fn test_update_dist_with_not_equal_types() {
todo!()
}
#[ignore = "requires PHPUnit mock of PackageInterface and ReflectionMethod for private getAvailableSources"]
#[test]
fn test_get_available_sources_update_sticks_to_same_source() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_update_metapackage() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_remove() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_metapackage_remove() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_install_preference_without_preference_dev() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_install_preference_without_preference_no_dev() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_install_preference_without_match_dev() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_install_preference_without_match_no_dev() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_install_preference_with_match_auto_dev() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_install_preference_with_match_auto_no_dev() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_install_preference_with_match_source() {
todo!()
}
#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"]
#[test]
fn test_install_preference_with_match_dist() {
todo!()
}
|