@@ -227,59 +227,17 @@ mod tests {
227
227
fs:: { self , File } ,
228
228
io:: Write ,
229
229
path:: Path ,
230
- str:: FromStr ,
231
230
} ;
232
231
233
- use rattler_conda_types:: { Platform , PrefixRecord , RepoDataRecord , Version } ;
234
- use url:: Url ;
232
+ use rattler_conda_types:: { Platform , RepoDataRecord } ;
235
233
236
- use crate :: {
237
- get_repodata_record,
238
- install:: {
239
- empty_trash, link_package, unlink_package, InstallDriver , InstallOptions , PythonInfo ,
240
- Transaction ,
241
- } ,
242
- } ;
243
-
244
- async fn link_ruff ( target_prefix : & Path , package_url : Url , sha256_hash : & str ) -> PrefixRecord {
245
- let package_path = tools:: download_and_cache_file_async ( package_url, sha256_hash)
246
- . await
247
- . unwrap ( ) ;
248
-
249
- let package_dir = tempfile:: TempDir :: new ( ) . unwrap ( ) ;
250
-
251
- // Create package cache
252
- rattler_package_streaming:: fs:: extract ( & package_path, package_dir. path ( ) ) . unwrap ( ) ;
253
-
254
- let py_info =
255
- PythonInfo :: from_version ( & Version :: from_str ( "3.10" ) . unwrap ( ) , None , Platform :: Linux64 )
256
- . unwrap ( ) ;
257
- let install_options = InstallOptions {
258
- python_info : Some ( py_info) ,
259
- ..InstallOptions :: default ( )
260
- } ;
261
-
262
- let install_driver = InstallDriver :: default ( ) ;
263
- // Link the package
264
- let paths = link_package (
265
- package_dir. path ( ) ,
266
- target_prefix,
267
- & install_driver,
268
- install_options,
269
- )
270
- . await
271
- . unwrap ( ) ;
272
-
273
- let repodata_record = get_repodata_record ( & package_path) ;
274
- // Construct a PrefixRecord for the package
275
-
276
- PrefixRecord :: from_repodata_record ( repodata_record, None , None , paths, None , None )
277
- }
234
+ use crate :: install:: test_utils:: download_and_get_prefix_record;
235
+ use crate :: install:: { empty_trash, unlink_package, InstallDriver , Transaction } ;
278
236
279
237
#[ tokio:: test]
280
238
async fn test_unlink_package ( ) {
281
239
let environment_dir = tempfile:: TempDir :: new ( ) . unwrap ( ) ;
282
- let prefix_record = link_ruff (
240
+ let prefix_record = download_and_get_prefix_record (
283
241
environment_dir. path ( ) ,
284
242
"https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda"
285
243
. parse ( )
@@ -308,6 +266,7 @@ mod tests {
308
266
let transaction = Transaction :: from_current_and_desired (
309
267
vec ! [ prefix_record. clone( ) ] ,
310
268
Vec :: < RepoDataRecord > :: new ( ) . into_iter ( ) ,
269
+ None ,
311
270
Platform :: current ( ) ,
312
271
)
313
272
. unwrap ( ) ;
@@ -328,7 +287,7 @@ mod tests {
328
287
#[ tokio:: test]
329
288
async fn test_unlink_package_python_noarch ( ) {
330
289
let target_prefix = tempfile:: TempDir :: new ( ) . unwrap ( ) ;
331
- let prefix_record = link_ruff (
290
+ let prefix_record = download_and_get_prefix_record (
332
291
target_prefix. path ( ) ,
333
292
"https://conda.anaconda.org/conda-forge/noarch/pytweening-1.0.4-pyhd8ed1ab_0.tar.bz2"
334
293
. parse ( )
@@ -370,6 +329,7 @@ mod tests {
370
329
let transaction = Transaction :: from_current_and_desired (
371
330
vec ! [ prefix_record. clone( ) ] ,
372
331
Vec :: < RepoDataRecord > :: new ( ) . into_iter ( ) ,
332
+ None ,
373
333
Platform :: current ( ) ,
374
334
)
375
335
. unwrap ( ) ;
@@ -404,6 +364,10 @@ mod tests {
404
364
#[ cfg( windows) ]
405
365
#[ tokio:: test]
406
366
async fn test_unlink_package_in_use ( ) {
367
+ use crate :: get_repodata_record;
368
+ use crate :: install:: link_package;
369
+ use crate :: install:: InstallOptions ;
370
+ use rattler_conda_types:: PrefixRecord ;
407
371
use std:: {
408
372
env:: { join_paths, split_paths, var_os} ,
409
373
io:: { BufRead , BufReader } ,
0 commit comments