-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(git-archive-file): add unit test
- Loading branch information
Showing
2 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
|
||
# Testcases issue https://github.com/tj/git-extras/issues/1081 | ||
class TestGitArchiveFile: | ||
def test_init(self, temp_repo): | ||
git = temp_repo.get_repo_git() | ||
tmp_file = temp_repo.get_file(0) | ||
temp_repo.writefile(tmp_file, "data") | ||
git.add(".") | ||
git.commit("-m", "test: add data") | ||
git.tag("0.1.0", "-m", "bump: 0.1.0") | ||
|
||
def test_archive_file_on_tags_branch(self, temp_repo): | ||
git = temp_repo.get_repo_git() | ||
git.checkout("-b", "tags0.1.0") | ||
temp_repo.invoke_installed_extras_command("archive-file") | ||
filename = "{0}.{1}.{2}".format(temp_repo.get_repo_dirname(), git.describe(), "zip") | ||
assert filename in os.listdir() | ||
|
||
def test_archive_file_on_any_not_tags_branch_without_default_branch(self, temp_repo): | ||
git = temp_repo.get_repo_git() | ||
git.checkout("-b", "not-tags-branch") | ||
temp_repo.invoke_installed_extras_command("archive-file") | ||
filename = "{0}.{1}.{2}.{3}".format( | ||
temp_repo.get_repo_dirname(), | ||
git.describe("--always", "--long"), | ||
"not-tags-branch", | ||
"zip") | ||
assert filename in os.listdir() | ||
|
||
def test_archive_file_on_any_not_tags_branch_with_default_branch(self, temp_repo): | ||
git = temp_repo.get_repo_git() | ||
git.checkout("master") | ||
git.config("git-extras.default-branch", "master") | ||
temp_repo.invoke_installed_extras_command("archive-file") | ||
filename = "{0}.{1}.{2}".format( | ||
temp_repo.get_repo_dirname(), | ||
git.describe("--always", "--long"), | ||
"zip") | ||
assert filename in os.listdir() |