@@ -529,10 +529,24 @@ async def test_gpu_device_ids_specific(self):
529529 )
530530
531531 @parameterized .expand ([
532- (False , "z" , ["--mount" , "type=bind,source=./foo,destination=/mnt,z" ]),
533- (False , "Z" , ["--mount" , "type=bind,source=./foo,destination=/mnt,Z" ]),
534- (True , "z" , ["-v" , "./foo:/mnt:z" ]),
535- (True , "Z" , ["-v" , "./foo:/mnt:Z" ]),
532+ (
533+ False ,
534+ "z" ,
535+ [
536+ "--mount" ,
537+ f"type=bind,source={ get_test_file_path ('test_dirname/foo' )} ,destination=/mnt,z" ,
538+ ],
539+ ),
540+ (
541+ False ,
542+ "Z" ,
543+ [
544+ "--mount" ,
545+ f"type=bind,source={ get_test_file_path ('test_dirname/foo' )} ,destination=/mnt,Z" ,
546+ ],
547+ ),
548+ (True , "z" , ["-v" , f"{ get_test_file_path ('test_dirname/foo' )} :/mnt:z" ]),
549+ (True , "Z" , ["-v" , f"{ get_test_file_path ('test_dirname/foo' )} :/mnt:Z" ]),
536550 ])
537551 async def test_selinux_volume (self , prefer_volume , selinux_type , expected_additional_args ):
538552 c = create_compose_mock ()
@@ -567,6 +581,62 @@ async def test_selinux_volume(self, prefer_volume, selinux_type, expected_additi
567581 ],
568582 )
569583
584+ @parameterized .expand ([
585+ (
586+ "absolute_path" ,
587+ get_test_file_path ('test_dirname/foo' ),
588+ [
589+ "--mount" ,
590+ f"type=bind,source={ get_test_file_path ('test_dirname/foo' )} ,destination=/mnt" ,
591+ ],
592+ ),
593+ (
594+ "relative_path" ,
595+ './foo' ,
596+ [
597+ "--mount" ,
598+ f"type=bind,source={ get_test_file_path ('test_dirname/foo' )} ,destination=/mnt" ,
599+ ],
600+ ),
601+ (
602+ "home_dir" ,
603+ '~/test_dirname/foo' ,
604+ [
605+ "--mount" ,
606+ f"type=bind,source={ os .path .expanduser ('~/test_dirname/foo' )} ,destination=/mnt" ,
607+ ],
608+ ),
609+ ])
610+ async def test_volumes_bind_mount_source (
611+ self , test_name : str , mount_source : str , expected_additional_args : list
612+ ) -> None :
613+ c = create_compose_mock ()
614+ cnt = get_minimal_container ()
615+
616+ # This is supposed to happen during `_parse_compose_file`
617+ # but that is probably getting skipped during testing
618+ cnt ["_service" ] = cnt ["service_name" ]
619+
620+ cnt ["volumes" ] = [
621+ {
622+ "type" : "bind" ,
623+ "source" : f"{ mount_source } " ,
624+ "target" : "/mnt" ,
625+ }
626+ ]
627+
628+ args = await container_to_args (c , cnt )
629+ self .assertEqual (
630+ args ,
631+ [
632+ "--name=project_name_service_name1" ,
633+ "-d" ,
634+ * expected_additional_args ,
635+ "--network=bridge:alias=service_name" ,
636+ "busybox" ,
637+ ],
638+ )
639+
570640 @parameterized .expand ([
571641 ("not_compat" , False , "test_project_name" , "test_project_name_network1" ),
572642 ("compat_no_dash" , True , "test_project_name" , "test_project_name_network1" ),
0 commit comments