Skip to content

Commit

Permalink
test(git-abort): add its unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
vanpipy committed Aug 23, 2023
1 parent 9fb4b5d commit f21a24a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 29 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ jobs:
pip install codespell==2.2
git grep --cached -l '' | grep -v -e 'History\.md' -e 'AUTHORS' -e 'man/.*\.1' -e 'man/.*\.html' | xargs codespell --ignore-words=.github/.ignore_words
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.10']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest==7.4.0
- name: Unit test
run: |
pytest
build:
strategy:
fail-fast: false
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/pull-request.yml

This file was deleted.

19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import subprocess
import tempfile
import pytest

@pytest.fixture(scope="module")
def git_repo():
tmp_dir = tempfile.TemporaryDirectory()
tmp_file_a = tempfile.TemporaryFile(mode="w+b", dir=tmp_dir.name)
tmp_file_b = tempfile.TemporaryFile(mode="w+b", dir=tmp_dir.name)
os.chdir(tmp_dir.name)
result = subprocess.run(["git", "init"], capture_output=True)
print(result)
result = subprocess.run(["git", "add", "."], capture_output=True)
print(result)
result = subprocess.run(["git", "commit", "-m", "initial commit"], capture_output=True)
print(result)
yield [tmp_dir, tmp_file_a, tmp_file_b]
tmp_dir.cleanup()
13 changes: 13 additions & 0 deletions tests/test_git-abort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class TestGitAbort:
def test_cherry_pick(self, git_repo):
print(git_repo)
assert 1 == 2

def test_merge(self, git_repo):
assert 2 == 3

def test_rebase(self):
assert 3 == 4

def test_revert(self):
assert 4 == 4

0 comments on commit f21a24a

Please sign in to comment.