Test self referencing 'file'

When specifying the 'file' key to a value of it's own name, test
that this works and does not cause a false positive circular reference
error.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-07-03 14:14:47 +01:00
parent 6a6e7934bd
commit c6e03d739d
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,16 @@
myweb:
extends:
file: specify-file-as-self.yml
service: web
environment:
- "BAR=1"
web:
extends:
file: specify-file-as-self.yml
service: otherweb
image: busybox
environment:
- "BAZ=3"
otherweb:
environment:
- "YEP=1"

View File

@ -413,6 +413,33 @@ class ExtendsTest(unittest.TestCase):
},
])
def test_self_referencing_file(self):
"""
We specify a 'file' key that is the filename we're already in.
"""
service_dicts = load_from_filename('tests/fixtures/extends/specify-file-as-self.yml')
self.assertEqual(service_dicts, [
{
'environment':
{
'YEP': '1', 'BAR': '1', 'BAZ': '3'
},
'image': 'busybox',
'name': 'myweb'
},
{
'environment':
{'YEP': '1'},
'name': 'otherweb'
},
{
'environment':
{'YEP': '1', 'BAZ': '3'},
'image': 'busybox',
'name': 'web'
}
])
def test_circular(self):
try:
load_from_filename('tests/fixtures/extends/circle-1.yml')