diff --git a/eden/integration/changes_test.py b/eden/integration/changes_test.py index 930ad124a75dd..81ed6f4025591 100644 --- a/eden/integration/changes_test.py +++ b/eden/integration/changes_test.py @@ -8,11 +8,16 @@ import sys -from facebook.eden.ttypes import Dtype, LostChangesReason, SmallChangeNotification +from facebook.eden.ttypes import ( + Dtype, + LargeChangeNotification, + LostChangesReason, + SmallChangeNotification, +) from .lib import testcase from .lib.journal_test_base import JournalTestBase, WindowsJournalTestBase -from .lib.thrift_objects import buildSmallChange, getLargeChangeSafe +from .lib.thrift_objects import buildLargeChange, buildSmallChange, getLargeChangeSafe if sys.platform == "win32": @@ -234,6 +239,20 @@ def test_modify_folder_chown(self): ] self.assertTrue(self.check_changes(changes.changes, expected_changes)) + def test_rename_folder(self): + self.mkdir("test_folder") + position = self.client.getCurrentJournalPosition(self.mount_path_bytes) + self.rename("test_folder", "best_folder") + changes = self.getChangesSinceV2(position=position) + expected_changes = [ + buildLargeChange( + LargeChangeNotification.DIRECTORYRENAMED, + from_bytes=b"test_folder", + to_bytes=b"best_folder", + ), + ] + self.assertTrue(self.check_changes(changes.changes, expected_changes)) + @testcase.eden_repo_test class ChangesTestWin(WindowsJournalTestBase): diff --git a/eden/integration/lib/thrift_objects.py b/eden/integration/lib/thrift_objects.py index f2956cfd8aa65..9f862ea9e16df 100644 --- a/eden/integration/lib/thrift_objects.py +++ b/eden/integration/lib/thrift_objects.py @@ -11,8 +11,12 @@ from facebook.eden.ttypes import ( Added, ChangeNotification, + CommitTransition, + DirectoryRenamed, Dtype, LargeChangeNotification, + LostChanges, + LostChangesReason, Modified, Removed, Renamed, @@ -85,3 +89,34 @@ def buildSmallChange( SmallChangeNotification(removed=Removed(fileType=fileType, path=path)) ) return ChangeNotification() + + +def buildLargeChange( + changeType: int, + from_bytes: Optional[bytes] = None, + to_bytes: Optional[bytes] = None, + lost_change_reason: Optional[LostChangesReason] = None, +) -> ChangeNotification: + if changeType == LargeChangeNotification.DIRECTORYRENAMED: + return ChangeNotification( + largeChange=LargeChangeNotification( + directoryRenamed=DirectoryRenamed( + from_PY_RESERVED_KEYWORD=from_bytes, to=to_bytes + ) + ) + ) + elif changeType == LargeChangeNotification.COMMITTRANSITION: + return ChangeNotification( + largeChange=LargeChangeNotification( + commitTransition=CommitTransition( + from_PY_RESERVED_KEYWORD=from_bytes, to=to_bytes + ) + ) + ) + elif changeType == LargeChangeNotification.LOSTCHANGES: + return ChangeNotification( + largeChange=LargeChangeNotification( + lostChanges=LostChanges(reason=lost_change_reason) + ) + ) + return ChangeNotification()