File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ pub trait RegistryClient: std::fmt::Debug + Send + Sync {
4646 async fn fetch ( & self , update_url : & UpdateUrl ) -> Result < AllPackageVersions , RegistryError > ;
4747}
4848
49- /// Production registry client that makes actual HTTP requests
49+ /// The real implementation of RegistryClientTrait which makes actual network
50+ /// requests
5051#[ derive( Debug ) ]
5152pub struct LiveRegistryClient {
5253 pub client : Client ,
Original file line number Diff line number Diff line change 88
99#[ test]
1010fn filters_out_deprecated_versions ( ) {
11+ // Simulate npm registry response with deprecated versions
1112 let package_meta = PackageMeta {
1213 name : "@eslint/js" . to_string ( ) ,
1314 versions : {
1415 let mut versions = BTreeMap :: new ( ) ;
16+ // Regular version
1517 versions. insert ( "9.38.0" . to_string ( ) , json ! ( { "version" : "9.38.0" } ) ) ;
18+ // Deprecated version
1619 versions. insert (
1720 "10.0.0" . to_string ( ) ,
1821 json ! ( { "version" : "10.0.0" , "deprecated" : "This version should not be used." } ) ,
1922 ) ;
23+ // Another regular version
2024 versions. insert ( "9.39.0" . to_string ( ) , json ! ( { "version" : "9.39.0" } ) ) ;
2125 versions
2226 } ,
2327 } ;
2428
29+ // Extract versions using the filtering logic
2530 let versions: Vec < String > = package_meta
2631 . versions
2732 . into_iter ( )
2833 . filter ( |( _, metadata) | metadata. get ( "deprecated" ) . is_none ( ) )
2934 . map ( |( version, _) | version)
3035 . collect ( ) ;
3136
37+ // Should only include non-deprecated versions
3238 assert_eq ! ( versions. len( ) , 2 ) ;
3339 assert ! ( versions. contains( & "9.38.0" . to_string( ) ) ) ;
3440 assert ! ( versions. contains( & "9.39.0" . to_string( ) ) ) ;
You can’t perform that action at this time.
0 commit comments