Exemplo n.º 1
0
 def assert_error(self, sha1result: SHA1Result, error_message: str) -> None:
     self.assertIsNotNone(sha1result, msg="Must pass a SHA1Result")
     self.assertEqual(SHA1Result.ERROR,
                      sha1result.getType(),
                      msg="SHA1Result must be an error")
     error = sha1result.get_error()
     self.assertIsNotNone(error)
     self.assertEqual(error_message, error.message)
Exemplo n.º 2
0
 def assert_error(self, sha1result: SHA1Result, error_message: str) -> None:
     self.assertIsNotNone(sha1result, msg="Must pass a SHA1Result")
     self.assertEqual(
         SHA1Result.ERROR, sha1result.getType(), msg="SHA1Result must be an error"
     )
     error = sha1result.get_error()
     self.assertIsNotNone(error)
     self.assertEqual(error_message, error.message)
Exemplo n.º 3
0
    def test_get_sha1(self) -> None:
        expected_sha1_for_hello = hashlib.sha1(b"hola\n").digest()
        result_for_hello = SHA1Result(expected_sha1_for_hello)

        expected_sha1_for_adir_file = hashlib.sha1(b"foo!\n").digest()
        result_for_adir_file = SHA1Result(expected_sha1_for_adir_file)

        self.assertEqual(
            [result_for_hello, result_for_adir_file],
            self.client.getSHA1(self.mount_path_bytes, [b"hello", b"adir/file"]),
        )
Exemplo n.º 4
0
 def assert_error(self, sha1result: SHA1Result,
                  error_message: Union[str, Pattern]) -> None:
     self.assertIsNotNone(sha1result, msg="Must pass a SHA1Result")
     self.assertEqual(SHA1Result.ERROR,
                      sha1result.getType(),
                      msg="SHA1Result must be an error")
     error = sha1result.get_error()
     self.assertIsNotNone(error)
     if isinstance(error_message, str):
         self.assertEqual(error_message, error.message)
     else:
         self.assertRegex(error.message, error_message)
Exemplo n.º 5
0
    def test_get_sha1(self):
        expected_sha1_for_hello = hashlib.sha1(b'hola\n').digest()
        result_for_hello = SHA1Result()
        result_for_hello.set_sha1(expected_sha1_for_hello)

        expected_sha1_for_adir_file = hashlib.sha1(b'foo!\n').digest()
        result_for_adir_file = SHA1Result()
        result_for_adir_file.set_sha1(expected_sha1_for_adir_file)

        self.assertEqual([
            result_for_hello,
            result_for_adir_file,
        ], self.client.getSHA1(self.mount, ['hello', 'adir/file']))
Exemplo n.º 6
0
 def assert_sha1_error(self, sha1result: SHA1Result,
                       error_message: Union[str, Pattern]) -> None:
     self.assertIsNotNone(sha1result, msg="Must pass a SHA1Result")
     self.assertEqual(SHA1Result.ERROR,
                      sha1result.getType(),
                      msg="SHA1Result must be an error")
     self.assert_eden_error(sha1result, error_message)
Exemplo n.º 7
0
    def test_get_sha1(self) -> None:
        expected_sha1_for_hello = hashlib.sha1(b"hola\n").digest()
        result_for_hello = SHA1Result(expected_sha1_for_hello)

        expected_sha1_for_adir_file = hashlib.sha1(b"foo!\n").digest()
        result_for_adir_file = SHA1Result(expected_sha1_for_adir_file)

        with self.get_thrift_client_legacy() as client:
            self.assertEqual(
                [result_for_hello, result_for_adir_file],
                client.getSHA1(
                    self.mount_path_bytes,
                    [b"hello", b"adir/file"],
                    sync=SyncBehavior(),
                ),
            )
Exemplo n.º 8
0
    def test_loaded_content(self, mock_debugInodeStatus, mock_getSHA1) -> None:
        instance = FakeEdenInstance(self.make_temporary_directory())
        checkout = instance.create_test_mount("path1")

        with open(checkout.path / "a", "wb") as f:
            f.write(b"foobar")

        mock_getSHA1.return_value = [SHA1Result(b"\x01\x02\x03\x04")]

        mock_debugInodeStatus.return_value = [
            TreeInodeDebugInfo(
                1,
                b"",
                True,
                b"abcd",
                [
                    TreeInodeEntryDebugInfo(b"a", 2, stat.S_IFREG, True, False,
                                            b"1234")
                ],
            )
        ]

        def fake_PrjGetOnDiskFileState(path: Path) -> PRJ_FILE_STATE:
            if path == checkout.path / "a":
                return PRJ_FILE_STATE.HydratedPlaceholder
            else:
                return PRJ_FILE_STATE.Placeholder

        tracker = ProblemCollector()
        check_loaded_content(
            tracker,
            typing.cast(EdenInstance, instance),
            checkout,
            fake_PrjGetOnDiskFileState,
        )

        self.assertEqual(
            tracker.problems[0].description(),
            "The on-disk file at a is out of sync from EdenFS. Expected SHA1: 01020304, on-disk SHA1: 8843d7f92416211de9ebb963ff4ce28125932878",
        )