Skip to content

Commit

Permalink
Move rename tests into OS specific versions
Browse files Browse the repository at this point in the history
Summary:
# Context
Tests are failing due to OS specfic versions

# This Diff
Move rename tests into NIX os tests. Windows versions will be added in a followup diff

Reviewed By: kavehahmadi60

Differential Revision: D67307721

fbshipit-source-id: 337d1959c633aa15c896798974a10de034b47781
  • Loading branch information
Chris Dinh authored and facebook-github-bot committed Dec 17, 2024
1 parent d542ece commit a90689e
Showing 1 changed file with 102 additions and 102 deletions.
204 changes: 102 additions & 102 deletions eden/integration/changes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,83 +157,6 @@ def test_remove_folder(self):
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))

def test_rename_include(self):
# Tests if a folder is renamed from an included directory to an not included directory
# and vice versa it shows up
self.mkdir("included_folder")
self.mkdir("not_included_folder")
self.mkdir("not_included_folder2")
self.repo_write_file("included_folder/test_file", "contents", add=False)
self.repo_write_file("not_included_folder/test_file2", "contents", add=False)
self.repo_write_file("not_included_folder/test_file3", "contents", add=False)
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
self.rename("included_folder/test_file", "not_included_folder/test_file")
self.rename("not_included_folder/test_file2", "included_folder/test_file2")
self.rename("not_included_folder/test_file3", "not_included_folder2/test_file3")
changes = self.getChangesSinceV2(
position=position, included_roots=["included_folder"]
)
# We expect changes involving included folders to be present and changes involving
# not_included folders to be ignored if they are not renamed to an included folder
expected_changes = [
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"included_folder/test_file",
to_path=b"not_included_folder/test_file",
),
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"not_included_folder/test_file2",
to_path=b"included_folder/test_file2",
),
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))

def test_rename_exclude(self):
# Tests if a folder is renamed from an excluded directory to an not excluded directory
# and vice versa it shows up

self.mkdir("not_excluded_folder")
self.mkdir("not_excluded_folder2")
self.mkdir("excluded_folder")
self.repo_write_file("not_excluded_folder/test_file", "contents", add=False)
self.repo_write_file("excluded_folder/test_file2", "contents", add=False)
self.repo_write_file("not_excluded_folder/test_file3", "contents", add=False)
self.repo_write_file("excluded_folder/test_file4", "contents", add=False)
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
self.rename("not_excluded_folder/test_file", "excluded_folder/test_file")
self.rename("excluded_folder/test_file2", "not_excluded_folder/test_file2")
self.rename("not_excluded_folder/test_file3", "not_excluded_folder2/test_file3")
self.rename("excluded_folder/test_file4", "excluded_folder/test_file4")
changes = self.getChangesSinceV2(
position=position, excluded_roots=["excluded_folder"]
)
# We expect changes involving not_excluded folders to be present and changes involving
# excluded folders to be ignored if they are not renamed to a not_excluded folder
expected_changes = [
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"not_excluded_folder/test_file",
to_path=b"excluded_folder/test_file",
),
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"excluded_folder/test_file2",
to_path=b"not_excluded_folder/test_file2",
),
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"not_excluded_folder/test_file3",
to_path=b"not_excluded_folder2/test_file3",
),
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))

def test_commit_transition(self):
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
self.mkdir("test_folder")
Expand Down Expand Up @@ -342,31 +265,6 @@ def test_truncated_journal(self):
self.assertEqual(changes2.changes, [])
self.assertTrue(self.check_changes(changes3.changes, expected_changes3))

def test_too_many_changes(self):
self.mkdir("test_folder")
expected_changes1 = []
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
# usually the max changes is 10k but for test speed reasons we set it to 100
# Each file add creates 2 changes, one for the add and one for the modify
for i in range(50):
expected_changes1 += self.add_file_expect(
f"test_folder/test_file{i}", f"{i}"
)
changes1 = self.getChangesSinceV2(position=position)
self.repo_write_file("test_folder/last_file", "i")
changes2 = self.getChangesSinceV2(position=position)
expected_changes2 = [
buildLargeChange(
LargeChangeNotification.LOSTCHANGES,
lost_change_reason=LostChangesReason.TOO_MANY_CHANGES,
),
]
self.assertTrue(len(expected_changes1) == 100)
self.assertTrue(len(changes1.changes) == 100)
self.assertTrue(len(changes2.changes) == 1)
self.assertTrue(self.check_changes(changes1.changes, expected_changes1))
self.assertTrue(self.check_changes(changes2.changes, expected_changes2))


# The following tests have different results based on platform

Expand Down Expand Up @@ -464,6 +362,108 @@ def test_rename_folder(self):
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))

def test_rename_include(self):
# Tests if a folder is renamed from an included directory to an not included directory
# and vice versa it shows up
self.mkdir("included_folder")
self.mkdir("not_included_folder")
self.mkdir("not_included_folder2")
self.repo_write_file("included_folder/test_file", "contents", add=False)
self.repo_write_file("not_included_folder/test_file2", "contents", add=False)
self.repo_write_file("not_included_folder/test_file3", "contents", add=False)
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
self.rename("included_folder/test_file", "not_included_folder/test_file")
self.rename("not_included_folder/test_file2", "included_folder/test_file2")
self.rename("not_included_folder/test_file3", "not_included_folder2/test_file3")
changes = self.getChangesSinceV2(
position=position, included_roots=["included_folder"]
)
# We expect changes involving included folders to be present and changes involving
# not_included folders to be ignored if they are not renamed to an included folder
expected_changes = [
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"included_folder/test_file",
to_path=b"not_included_folder/test_file",
),
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"not_included_folder/test_file2",
to_path=b"included_folder/test_file2",
),
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))

def test_rename_exclude(self):
# Tests if a folder is renamed from an excluded directory to an not excluded directory
# and vice versa it shows up

self.mkdir("not_excluded_folder")
self.mkdir("not_excluded_folder2")
self.mkdir("excluded_folder")
self.repo_write_file("not_excluded_folder/test_file", "contents", add=False)
self.repo_write_file("excluded_folder/test_file2", "contents", add=False)
self.repo_write_file("not_excluded_folder/test_file3", "contents", add=False)
self.repo_write_file("excluded_folder/test_file4", "contents", add=False)
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
self.rename("not_excluded_folder/test_file", "excluded_folder/test_file")
self.rename("excluded_folder/test_file2", "not_excluded_folder/test_file2")
self.rename("not_excluded_folder/test_file3", "not_excluded_folder2/test_file3")
self.rename("excluded_folder/test_file4", "excluded_folder/test_file4")
changes = self.getChangesSinceV2(
position=position, excluded_roots=["excluded_folder"]
)
# We expect changes involving not_excluded folders to be present and changes involving
# excluded folders to be ignored if they are not renamed to a not_excluded folder
expected_changes = [
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"not_excluded_folder/test_file",
to_path=b"excluded_folder/test_file",
),
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"excluded_folder/test_file2",
to_path=b"not_excluded_folder/test_file2",
),
buildSmallChange(
SmallChangeNotification.RENAMED,
Dtype.REGULAR,
from_path=b"not_excluded_folder/test_file3",
to_path=b"not_excluded_folder2/test_file3",
),
]
self.assertTrue(self.check_changes(changes.changes, expected_changes))

def test_too_many_changes(self):
self.mkdir("test_folder")
expected_changes1 = []
position = self.client.getCurrentJournalPosition(self.mount_path_bytes)
# usually the max changes is 10k but for test speed reasons we set it to 100
# Each file add creates 2 changes, one for the add and one for the modify
for i in range(50):
expected_changes1 += self.add_file_expect(
f"test_folder/test_file{i}", f"{i}"
)
changes1 = self.getChangesSinceV2(position=position)
self.repo_write_file("test_folder/last_file", "i")
changes2 = self.getChangesSinceV2(position=position)
expected_changes2 = [
buildLargeChange(
LargeChangeNotification.LOSTCHANGES,
lost_change_reason=LostChangesReason.TOO_MANY_CHANGES,
),
]
self.assertTrue(len(expected_changes1) == 100)
self.assertTrue(len(changes1.changes) == 100)
self.assertTrue(len(changes2.changes) == 1)
self.assertTrue(self.check_changes(changes1.changes, expected_changes1))
self.assertTrue(self.check_changes(changes2.changes, expected_changes2))


@testcase.eden_repo_test
class ChangesTestWin(WindowsJournalTestBase):
Expand Down

0 comments on commit a90689e

Please sign in to comment.