code: def test_should_not_checkout_upon_corrupted_local_hardlink_cache(
      mocker, tmp_dir, dvc, copy_script
  ):
      tmp_dir.gen("foo", "foo")
      dvc.cache.local.cache_types = ["hardlink"]
  
      stage = dvc.run(
          deps=["foo"],
          outs=["bar"],
          cmd="python copy.py foo bar",
          name="copy",
      )
  
      os.chmod("bar", 0o644)
      with open("bar", "w", encoding="utf-8") as fd:
          fd.write("corrupting the output cache")
  
      spy_checkout = mocker.spy(stage.outs[0], "checkout")
      from dvc.stage import run as stage_run
  
      spy_run = mocker.spy(stage_run, "cmd_run")
  
      with dvc.lock:
          stage.run()
  
          spy_run.assert_called_once()
          spy_checkout.assert_not_called()
  
imports: import logging
  import os
  import textwrap
  import uuid
  import pytest
  from funcy import get_in
  from dvc.cli import main
  from dvc.dependency import ParamsDependency
  from dvc.dependency.base import DependencyDoesNotExistError
  from dvc.dvcfile import LOCK_FILE, PROJECT_FILE, load_file
  from dvc.exceptions import ArgumentDuplicationError, CircularDependencyError, CyclicGraphError, InvalidArgumentError, OutputDuplicationError, OverlappingOutputPathsError
  from dvc.stage import PipelineStage
  from dvc.stage.exceptions import DuplicateStageName, InvalidStageName, StagePathNotDirectoryError, StagePathNotFoundError, StagePathOutsideError
  from dvc.utils.serialize import load_yaml
label_desc: Use image node_id 31 for calling a global function with example usage: test_should_not_checkout_upon_corrupted_local_hardlink_cache(mocker, tmp_dir, dvc, copy_script) without return types