1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Handle Manager.dump with an empty Zone

This commit is contained in:
Ross McFarland
2017-10-13 13:15:24 -07:00
parent 9e52b5d701
commit ffeceb39b1
2 changed files with 15 additions and 1 deletions

View File

@@ -11,7 +11,7 @@ from importlib import import_module
from os import environ
import logging
from .provider.base import BaseProvider
from .provider.base import BaseProvider, Plan
from .provider.yaml import YamlProvider
from .record import Record
from .yaml import safe_load
@@ -362,6 +362,8 @@ class Manager(object):
source.populate(zone, lenient=lenient)
plan = target.plan(zone)
if plan is None:
plan = Plan(zone, zone, [])
target.apply(plan)
def validate_configs(self):

View File

@@ -11,6 +11,7 @@ from unittest import TestCase
from octodns.record import Record
from octodns.manager import _AggregateTarget, MainThreadExecutor, Manager
from octodns.yaml import safe_load
from octodns.zone import Zone
from helpers import GeoProvider, NoSshFpProvider, SimpleProvider, \
@@ -211,6 +212,17 @@ class TestManager(TestCase):
with self.assertRaises(IOError):
manager.dump('unknown.zone.', tmpdir.dirname, False, 'in')
def test_dump_empty(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname
manager = Manager(get_config_filename('simple.yaml'))
manager.dump('empty.', tmpdir.dirname, False, 'in')
with open(join(tmpdir.dirname, 'empty.yaml')) as fh:
data = safe_load(fh, False)
self.assertFalse(data)
def test_validate_configs(self):
Manager(get_config_filename('simple-validate.yaml')).validate_configs()