Skip to content

Commit

Permalink
ChangesSinceV2 folder add/remove tests
Browse files Browse the repository at this point in the history
Summary:
# Context

We are introducing EdenFS notifications to support scalable and ergonomic file system notifications for EdenFS mounts.

# This Diff
Add tests for adding/removing folder notifications

# Technical Details

# Discussion Points

Reviewed By: jdelliot

Differential Revision: D66841006

fbshipit-source-id: 00cd26681becd107b6e76623c264d220c47f66a2
  • Loading branch information
Chris Dinh authored and facebook-github-bot committed Dec 7, 2024
1 parent d50b916 commit 5491081
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions eden/integration/changes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def setup_test_rename_file(self) -> ChangesSinceV2Result:
self.rename("test_file", "best_file")
return self.getChangesSinceV2(position=position)

def repo_rmdir(self, path) -> None:
self.rmdir(path)


class WindowsTestBase(ChangesTestBase):
SYNC_MAX: int = 1
Expand Down Expand Up @@ -179,6 +182,16 @@ def rename(self, from_path, to_path) -> None:
super().rename(from_path, to_path)
self.syncProjFS(position)

def mkdir(self, path) -> None:
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
super().mkdir(path)
self.syncProjFS(position)

def repo_rmdir(self, path) -> None:
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
super().rmdir(path)
self.syncProjFS(position)


if sys.platform == "win32":
testBase = WindowsTestBase
Expand Down Expand Up @@ -228,6 +241,34 @@ def test_remove_file(self):
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))

def test_add_folder(self):
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
# self.repo_write_file("test_folder/test_file", "", add=False)
self.mkdir("test_folder")
changes = self.getChangesSinceV2(position=position)
expected_changes = [
buildSmallChange(
SmallChangeNotification.ADDED,
Dtype.DIR,
path=b"test_folder",
),
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))

def test_remove_folder(self):
self.mkdir("test_folder")
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
self.repo_rmdir("test_folder")
changes = self.getChangesSinceV2(position=position)
expected_changes = [
buildSmallChange(
SmallChangeNotification.REMOVED,
Dtype.DIR,
path=b"test_folder",
),
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))


# The following tests have different results based on platform

Expand Down

0 comments on commit 5491081

Please sign in to comment.