MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / test_clone

Function test_clone

tests/store_test.py:82–105  ·  view source on GitHub ↗
(store, tempdir_factory, caplog)

Source from the content-addressed store, hash-verified

80
81
82def test_clone(store, tempdir_factory, caplog):
83 path = git_dir(tempdir_factory)
84 with cwd(path):
85 git_commit()
86 rev = git.head_rev(path)
87 git_commit()
88
89 ret = store.clone(path, rev)
90 # Should have printed some stuff
91 assert caplog.record_tuples[0][-1].startswith(
92 'Initializing environment for ',
93 )
94
95 # Should return a directory inside of the store
96 assert os.path.exists(ret)
97 assert ret.startswith(store.directory)
98 # Directory should start with `repo`
99 _, dirname = os.path.split(ret)
100 assert dirname.startswith('repo')
101 # Should be checked out to the rev we specified
102 assert git.head_rev(ret) == rev
103
104 # Assert there's an entry in the sqlite db for this
105 assert _select_all_repos(store) == [(path, rev, ret)]
106
107
108def test_warning_for_deprecated_stages_on_init(store, tempdir_factory, caplog):

Callers

nothing calls this directly

Calls 6

git_dirFunction · 0.90
cwdFunction · 0.90
git_commitFunction · 0.90
_select_all_reposFunction · 0.85
cloneMethod · 0.80
existsMethod · 0.80

Tested by

no test coverage detected