From c6e03d739d3318e67aa8b3eb0df091cbd775ba56 Mon Sep 17 00:00:00 2001 From: Mazz Mosley Date: Fri, 3 Jul 2015 14:14:47 +0100 Subject: [PATCH] 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 --- .../fixtures/extends/specify-file-as-self.yml | 16 +++++++++++ tests/unit/config_test.py | 27 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/fixtures/extends/specify-file-as-self.yml diff --git a/tests/fixtures/extends/specify-file-as-self.yml b/tests/fixtures/extends/specify-file-as-self.yml new file mode 100644 index 000000000..7e2499762 --- /dev/null +++ b/tests/fixtures/extends/specify-file-as-self.yml @@ -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" diff --git a/tests/unit/config_test.py b/tests/unit/config_test.py index 3e9b56c3d..d66b9fbb8 100644 --- a/tests/unit/config_test.py +++ b/tests/unit/config_test.py @@ -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')