@@ -381,3 +381,36 @@ def test_volume_path(self):
381381 ]
382382
383383 self .assertEqual (set (dicts [0 ]['volumes' ]), set (paths ))
384+
385+
386+ class BuildPathTest (unittest .TestCase ):
387+ def setUp (self ):
388+ self .abs_context_path = os .path .join (os .getcwd (), 'tests/fixtures/build-ctx' )
389+
390+ def test_nonexistent_path (self ):
391+ options = {'build' : 'nonexistent.path' }
392+ self .assertRaises (
393+ config .ConfigurationError ,
394+ lambda : config .make_service_dict ('foo' , options , 'tests/fixtures/build-path' ),
395+ )
396+
397+ def test_relative_path (self ):
398+ relative_build_path = '../build-ctx/'
399+ service_dict = config .make_service_dict (
400+ 'relpath' ,
401+ {'build' : relative_build_path },
402+ working_dir = 'tests/fixtures/build-path'
403+ )
404+ self .assertEquals (service_dict ['build' ], self .abs_context_path )
405+
406+ def test_absolute_path (self ):
407+ service_dict = config .make_service_dict (
408+ 'abspath' ,
409+ {'build' : self .abs_context_path },
410+ working_dir = 'tests/fixtures/build-path'
411+ )
412+ self .assertEquals (service_dict ['build' ], self .abs_context_path )
413+
414+ def test_from_file (self ):
415+ service_dict = config .load ('tests/fixtures/build-path/docker-compose.yml' )
416+ self .assertEquals (service_dict , [{'name' : 'foo' , 'build' : self .abs_context_path }])
0 commit comments