@@ -163,110 +163,5 @@ impl Default for TestBuilder {
163163}
164164
165165#[ cfg( test) ]
166- mod tests {
167- use {
168- super :: * ,
169- crate :: {
170- instance:: { InstanceState , ValidInstance :: * } ,
171- test:: expect:: { expect, ExpectedInstance } ,
172- } ,
173- } ;
174-
175- #[ test]
176- fn test_builder_basic_usage ( ) {
177- let ctx = TestBuilder :: new ( )
178- . with_package ( json ! ( {
179- "name" : "package-a" ,
180- "version" : "1.0.0"
181- } ) )
182- . build_and_visit_packages ( ) ;
183-
184- expect ( & ctx) . to_have_instances ( vec ! [ ExpectedInstance {
185- state: InstanceState :: valid( IsLocalAndValid ) ,
186- dependency_name: "package-a" ,
187- id: "package-a in /version of package-a" ,
188- actual: "1.0.0" ,
189- expected: Some ( "1.0.0" ) ,
190- overridden: None ,
191- } ] ) ;
192- }
193-
194- #[ test]
195- fn test_builder_with_version_group ( ) {
196- let ctx = TestBuilder :: new ( )
197- . with_package ( json ! ( {
198- "name" : "package-a" ,
199- "version" : "1.0.0" ,
200- "dependencies" : { "foo" : "1.0.0" }
201- } ) )
202- . with_version_group ( json ! ( {
203- "dependencies" : [ "foo" ] ,
204- "pinVersion" : "2.0.0"
205- } ) )
206- . build_and_visit_packages ( ) ;
207-
208- // The test should show that foo gets pinned to 2.0.0
209- assert ! ( ctx. instances. len( ) > 1 ) ;
210- }
211-
212- #[ test]
213- fn test_builder_with_multiple_packages ( ) {
214- let ctx = TestBuilder :: new ( )
215- . with_packages ( vec ! [
216- json!( { "name" : "package-a" , "version" : "1.0.0" } ) ,
217- json!( { "name" : "package-b" , "version" : "2.0.0" } ) ,
218- ] )
219- . build_and_visit_packages ( ) ;
220-
221- assert_eq ! ( ctx. instances. len( ) , 2 ) ;
222- }
223-
224- #[ test]
225- fn test_builder_with_strict_mode ( ) {
226- let ctx = TestBuilder :: new ( )
227- . with_package ( json ! ( {
228- "name" : "package-a" ,
229- "version" : "1.0.0" ,
230- "dependencies" : { "package-a" : "workspace:*" }
231- } ) )
232- . with_strict ( true )
233- . build_and_visit_packages ( ) ;
234-
235- // In strict mode, workspace protocol should be invalid when differs from local
236- assert ! ( ctx. instances. iter( ) . any( |i| i. state. borrow( ) . is_invalid( ) ) ) ;
237- }
238-
239- #[ tokio:: test]
240- async fn test_builder_with_registry_updates ( ) {
241- let ctx = TestBuilder :: new ( )
242- . with_package ( json ! ( {
243- "name" : "package-a" ,
244- "dependencies" : { "foo" : "1.0.0" }
245- } ) )
246- . with_registry_updates ( json ! ( { "foo" : [ "1.0.0" , "2.0.0" ] } ) )
247- . build_with_registry_and_visit ( )
248- . await ;
249-
250- // Should show registry update available
251- assert ! ( ctx. instances. iter( ) . any( |i| i. state. borrow( ) . is_outdated( ) ) ) ;
252- }
253-
254- #[ tokio:: test]
255- async fn test_builder_with_update_target ( ) {
256- use crate :: cli:: UpdateTarget ;
257-
258- let ctx = TestBuilder :: new ( )
259- . with_package ( json ! ( {
260- "name" : "package-a" ,
261- "dependencies" : { "foo" : "1.0.0" }
262- } ) )
263- . with_update_target ( UpdateTarget :: Minor )
264- . with_registry_updates ( json ! ( { "foo" : [ "1.0.0" , "1.1.0" , "2.0.0" ] } ) )
265- . build_with_registry_and_visit ( )
266- . await ;
267-
268- // Should target minor updates (1.1.0) not latest (2.0.0)
269- let foo_instance = ctx. instances . iter ( ) . find ( |i| i. descriptor . internal_name == "foo" ) . unwrap ( ) ;
270- assert_eq ! ( foo_instance. expected_specifier. borrow( ) . as_ref( ) . unwrap( ) . get_raw( ) , "1.1.0" ) ;
271- }
272- }
166+ #[ path = "builder_test.rs" ]
167+ mod builder_test;
0 commit comments