diff options
| author | Mike Frysinger <vapier@google.com> | 2026-03-06 17:31:33 -0500 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-03-12 20:09:19 -0700 |
| commit | 551087cd980976775470cde5f7ede264a90b5349 (patch) | |
| tree | 1d8470bd651a65e798af5454ac9cf05d9f3e917e /tests/test_wrapper.py | |
| parent | 8da56a0cc5e936646b82ebf0e9fa6d61b4ba19c7 (diff) | |
| download | git-repo-551087cd980976775470cde5f7ede264a90b5349.tar.gz | |
tests: add a util module for sharing code
We've started duplicating code among test modules. Start a common
utils module to hold that, and migrate over TempGitTree to start.
Change-Id: I10b2abd133535c90fbda4d6686602d7e5861d875
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/559041
Tested-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Mike Frysinger <vapier@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'tests/test_wrapper.py')
| -rw-r--r-- | tests/test_wrapper.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index 77ceda8f7..a38705675 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py | |||
| @@ -23,7 +23,8 @@ import tempfile | |||
| 23 | import unittest | 23 | import unittest |
| 24 | from unittest import mock | 24 | from unittest import mock |
| 25 | 25 | ||
| 26 | import git_command | 26 | import utils_for_test |
| 27 | |||
| 27 | import main | 28 | import main |
| 28 | import wrapper | 29 | import wrapper |
| 29 | 30 | ||
| @@ -408,18 +409,7 @@ class GitCheckoutTestCase(RepoWrapperTestCase): | |||
| 408 | remote = os.path.join(cls.GIT_DIR, "remote") | 409 | remote = os.path.join(cls.GIT_DIR, "remote") |
| 409 | os.mkdir(remote) | 410 | os.mkdir(remote) |
| 410 | 411 | ||
| 411 | # Tests need to assume, that main is default branch at init, | 412 | utils_for_test.init_git_tree(remote) |
| 412 | # which is not supported in config until 2.28. | ||
| 413 | if git_command.git_require((2, 28, 0)): | ||
| 414 | initstr = "--initial-branch=main" | ||
| 415 | else: | ||
| 416 | # Use template dir for init. | ||
| 417 | templatedir = tempfile.mkdtemp(prefix=".test-template") | ||
| 418 | with open(os.path.join(templatedir, "HEAD"), "w") as fp: | ||
| 419 | fp.write("ref: refs/heads/main\n") | ||
| 420 | initstr = "--template=" + templatedir | ||
| 421 | |||
| 422 | run_git("init", initstr, cwd=remote) | ||
| 423 | run_git("commit", "--allow-empty", "-minit", cwd=remote) | 413 | run_git("commit", "--allow-empty", "-minit", cwd=remote) |
| 424 | run_git("branch", "stable", cwd=remote) | 414 | run_git("branch", "stable", cwd=remote) |
| 425 | run_git("tag", "v1.0", cwd=remote) | 415 | run_git("tag", "v1.0", cwd=remote) |
