mirror of
https://github.com/docker/compose.git
synced 2025-07-24 06:04:57 +02:00
Merge pull request #3449 from Andrey9kin/ready/3281
Fix #3281: Unexpected result when using build args with default values
This commit is contained in:
commit
21f20cbc9b
@ -95,4 +95,4 @@ def microseconds_from_time_nano(time_nano):
|
|||||||
|
|
||||||
|
|
||||||
def build_string_dict(source_dict):
|
def build_string_dict(source_dict):
|
||||||
return dict((k, str(v)) for k, v in source_dict.items())
|
return dict((k, str(v if v is not None else '')) for k, v in source_dict.items())
|
||||||
|
@ -715,7 +715,35 @@ class ConfigTest(unittest.TestCase):
|
|||||||
).services[0]
|
).services[0]
|
||||||
assert 'args' in service['build']
|
assert 'args' in service['build']
|
||||||
assert 'foo' in service['build']['args']
|
assert 'foo' in service['build']['args']
|
||||||
assert service['build']['args']['foo'] == 'None'
|
assert service['build']['args']['foo'] == ''
|
||||||
|
|
||||||
|
# If build argument is None then it will be converted to the empty
|
||||||
|
# string. Make sure that int zero kept as it is, i.e. not converted to
|
||||||
|
# the empty string
|
||||||
|
def test_build_args_check_zero_preserved(self):
|
||||||
|
service = config.load(
|
||||||
|
build_config_details(
|
||||||
|
{
|
||||||
|
'version': '2',
|
||||||
|
'services': {
|
||||||
|
'web': {
|
||||||
|
'build': {
|
||||||
|
'context': '.',
|
||||||
|
'dockerfile': 'Dockerfile-alt',
|
||||||
|
'args': {
|
||||||
|
'foo': 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'tests/fixtures/extends',
|
||||||
|
'filename.yml'
|
||||||
|
)
|
||||||
|
).services[0]
|
||||||
|
assert 'args' in service['build']
|
||||||
|
assert 'foo' in service['build']['args']
|
||||||
|
assert service['build']['args']['foo'] == '0'
|
||||||
|
|
||||||
def test_load_with_multiple_files_mismatched_networks_format(self):
|
def test_load_with_multiple_files_mismatched_networks_format(self):
|
||||||
base_file = config.ConfigFile(
|
base_file = config.ConfigFile(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user