| 310 | |
| 311 | |
| 312 | def test_checkout_moved_cache_dir_with_symlinks(tmp_dir, dvc): |
| 313 | tmp_dir.gen({"foo": "foo", "data": {"file": "file"}}) |
| 314 | ret = main(["config", "cache.type", "symlink"]) |
| 315 | assert ret == 0 |
| 316 | |
| 317 | ret = main(["add", "foo"]) |
| 318 | assert ret == 0 |
| 319 | |
| 320 | ret = main(["add", "data"]) |
| 321 | assert ret == 0 |
| 322 | |
| 323 | assert system.is_symlink("foo") |
| 324 | old_foo_link = os.path.realpath("foo") |
| 325 | |
| 326 | assert system.is_symlink(os.path.join("data", "file")) |
| 327 | old_data_link = os.path.realpath(os.path.join("data", "file")) |
| 328 | |
| 329 | old_cache_dir = str(tmp_dir / ".dvc" / "cache") |
| 330 | new_cache_dir = str(tmp_dir / ".dvc" / "cache_new") |
| 331 | os.rename(old_cache_dir, new_cache_dir) |
| 332 | |
| 333 | ret = main(["cache", "dir", new_cache_dir]) |
| 334 | assert ret == 0 |
| 335 | |
| 336 | ret = main(["checkout", "-f"]) |
| 337 | assert ret == 0 |
| 338 | |
| 339 | assert system.is_symlink("foo") |
| 340 | new_foo_link = os.path.realpath("foo") |
| 341 | |
| 342 | assert system.is_symlink(os.path.join("data", "file")) |
| 343 | new_data_link = os.path.realpath(os.path.join("data", "file")) |
| 344 | |
| 345 | assert relpath(old_foo_link, old_cache_dir) == relpath(new_foo_link, new_cache_dir) |
| 346 | |
| 347 | assert relpath(old_data_link, old_cache_dir) == relpath( |
| 348 | new_data_link, new_cache_dir |
| 349 | ) |
| 350 | |
| 351 | |
| 352 | def test_checkout_no_checksum(tmp_dir, dvc): |