code: def test_clear_on_gc(tmp_dir, dvc, index):
      (foo,) = tmp_dir.dvc_gen({"dir": {"foo": "foo content"}})
      dvc.push()
      dvc.remove(foo.relpath)
  
      assert list(index.hashes())
      dvc.gc(workspace=True, cloud=True)
      assert not list(index.hashes())
  
file_path: dvc/tests/func/data/db/test_index.py
imports: import os
  import pytest
  from dvc.exceptions import DownloadError, UploadError
  from dvc.utils.fs import remove
  from dvc_data.hashfile.db import get_index
label_desc: Use image node_id 5 for calling a global function with example usage: test_clear_on_gc(tmp_dir, dvc, index) without return types