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

Merge pull request #997 from octodns/ownership-remove-last-change

fix issue in OwnershipProcessor when last change is removed
This commit is contained in:
Ross McFarland
2023-05-13 17:49:05 -07:00
committed by GitHub
3 changed files with 25 additions and 1 deletions

View File

@@ -29,6 +29,7 @@
* Added simple IgnoreRootNsFilter
* Minor refactor on YamlProvider to add get_filenames making it a bit easier to
create specialized providers inheriting from it
* Fixed bug in OwnershipProcessor when all changes were removed from plans
## v0.9.21 - 2022-10-16 - Last of the oughts

View File

@@ -90,7 +90,9 @@ class OwnershipProcessor(BaseProcessor):
# change is we should do
filtered_changes.append(change)
if plan.changes != filtered_changes:
if not filtered_changes:
return None
elif plan.changes != filtered_changes:
return Plan(
plan.existing,
plan.desired,

View File

@@ -7,6 +7,7 @@ from unittest import TestCase
from helpers import PlannableProvider
from octodns.processor.ownership import OwnershipProcessor
from octodns.provider.plan import Plan
from octodns.record import Delete, Record
from octodns.zone import Zone
@@ -119,3 +120,23 @@ class TestOwnershipProcessor(TestCase):
self.assertTrue(got)
self.assertEqual(plan, got)
self.assertEqual(len(plan.changes), len(got.changes))
def test_remove_last_change(self):
ownership = OwnershipProcessor('ownership')
record = Record.new(
zone, 'a', {'ttl': 30, 'type': 'A', 'value': '4.4.4.4'}
)
existing = Zone('unit.tests.', [])
existing.add_record(record)
desired = Zone('unit.tests.', [])
change = Delete(record)
plan = Plan(
existing=existing, desired=desired, changes=[change], exists=True
)
self.assertEqual(1, len(plan.changes))
plan = ownership.process_plan(plan)
self.assertFalse(plan)