-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,23 @@ | |
class AddTestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.tmpdir = tempfile.mkdtemp() | ||
# Setup git to have a proper user and email | ||
gitconfig = git.config.get_config_path("global") | ||
gc = git.GitConfigParser(gitconfig, read_only=False) | ||
|
||
try: | ||
name = gc.get_value("user", "name") | ||
except: | ||
name = None | ||
if not name: | ||
gc.set_value("user", "name", "test") | ||
try: | ||
email = gc.get_value("user", "email") | ||
except: | ||
email = None | ||
if not email: | ||
gc.set_value("user", "email", "[email protected]") | ||
gc.release() | ||
|
||
def cleanUp(self): | ||
shutil.rmtree(self.tmpdir) | ||
|
@@ -58,7 +75,7 @@ def test_add(self): | |
"origin", | ||
"example1-feature1", | ||
) | ||
# Check the proper order of the commits, like git log --pretty=%s | ||
repo = git.Repo(self.tmpdir) | ||
# Check the proper order of the commits, like git log --pretty=%s | ||
commits = [x.summary for x in repo.iter_commits("example1-final")] | ||
self.assertEqual(commits, expected_commits) |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
import unittest | ||
|
@@ -11,6 +12,23 @@ | |
class RemoveTestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.tmpdir = tempfile.mkdtemp() | ||
# Setup git to have a proper user and email | ||
gitconfig = git.config.get_config_path("global") | ||
gc = git.GitConfigParser(gitconfig, read_only=False) | ||
|
||
try: | ||
name = gc.get_value("user", "name") | ||
except: | ||
name = None | ||
if not name: | ||
gc.set_value("user", "name", "test") | ||
try: | ||
email = gc.get_value("user", "email") | ||
except: | ||
email = None | ||
if not email: | ||
gc.set_value("user", "email", "[email protected]") | ||
gc.release() | ||
|
||
def cleanUp(self): | ||
shutil.rmtree(self.tmpdir) | ||
|
@@ -44,7 +62,7 @@ def test_remove(self): | |
expected_commits = ["Second commit", "Initial commit"] | ||
guw = GUW(tomli.loads(config)) | ||
guw.remove(False, True, True, self.tmpdir, "example1-feature2") | ||
# Check the proper order of the commits, like git log --pretty=%s | ||
repo = git.Repo(self.tmpdir) | ||
# Check the proper order of the commits, like git log --pretty=%s | ||
commits = [x.summary for x in repo.iter_commits("example1-final")] | ||
self.assertEqual(commits, expected_commits) |