Fix a bug in ExtendsResolver where the service name of the extended service was wrong.
This bug can be seen by the change to the test case. When the extended service uses a different name, the error was reported incorrectly. By fixing this bug we can simplify self.signature and self.detect_cycles to always use self.service_name. Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
a92d86308f
commit
5e97b806d5
4 changed files with 25 additions and 22 deletions
2
tests/fixtures/extends/circle-1.yml
vendored
2
tests/fixtures/extends/circle-1.yml
vendored
|
|
@ -5,7 +5,7 @@ bar:
|
|||
web:
|
||||
extends:
|
||||
file: circle-2.yml
|
||||
service: web
|
||||
service: other
|
||||
baz:
|
||||
image: busybox
|
||||
quux:
|
||||
|
|
|
|||
2
tests/fixtures/extends/circle-2.yml
vendored
2
tests/fixtures/extends/circle-2.yml
vendored
|
|
@ -2,7 +2,7 @@ foo:
|
|||
image: busybox
|
||||
bar:
|
||||
image: busybox
|
||||
web:
|
||||
other:
|
||||
extends:
|
||||
file: circle-1.yml
|
||||
service: web
|
||||
|
|
|
|||
|
|
@ -1080,18 +1080,19 @@ class ExtendsTest(unittest.TestCase):
|
|||
]))
|
||||
|
||||
def test_circular(self):
|
||||
try:
|
||||
with pytest.raises(config.CircularReference) as exc:
|
||||
load_from_filename('tests/fixtures/extends/circle-1.yml')
|
||||
raise Exception("Expected config.CircularReference to be raised")
|
||||
except config.CircularReference as e:
|
||||
self.assertEqual(
|
||||
[(os.path.basename(filename), service_name) for (filename, service_name) in e.trail],
|
||||
[
|
||||
('circle-1.yml', 'web'),
|
||||
('circle-2.yml', 'web'),
|
||||
('circle-1.yml', 'web'),
|
||||
],
|
||||
)
|
||||
|
||||
path = [
|
||||
(os.path.basename(filename), service_name)
|
||||
for (filename, service_name) in exc.value.trail
|
||||
]
|
||||
expected = [
|
||||
('circle-1.yml', 'web'),
|
||||
('circle-2.yml', 'other'),
|
||||
('circle-1.yml', 'web'),
|
||||
]
|
||||
self.assertEqual(path, expected)
|
||||
|
||||
def test_extends_validation_empty_dictionary(self):
|
||||
with self.assertRaisesRegexp(ConfigurationError, 'service'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue