Skip to content

Commit cca4403

Browse files
authored
Refactor tests to remove the embedded git (#32)
* refactor tests to remove the embedded git * add a blank file to commit the data folder * remove reset from commit test * test with .gitconfig * edit conftest * use monkeypatch in conftest * small fix * try with os * new try with os * try with monkeypatch and committer * try with monkeypatch with author and committer * address review comments
1 parent 94b9870 commit cca4403

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+116
-983
lines changed

src/subcommand/commit_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <git2.h>
22
#include <unistd.h>
33

4-
#include "commit_subcommand.hpp"
4+
#include "../subcommand/commit_subcommand.hpp"
55
#include "../wrapper/index_wrapper.hpp"
66
#include "../wrapper/repository_wrapper.hpp"
77

test/conftest.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
from pathlib import Path
33
import pytest
4+
import subprocess
5+
46

57
# Fixture to run test in current tmp_path
68
@pytest.fixture
@@ -15,7 +17,21 @@ def git2cpp_path():
1517
return Path(__file__).parent.parent / 'build' / 'git2cpp'
1618

1719
@pytest.fixture
18-
def rename_git():
19-
os.rename("test/data/status_data/embedded_git/", "test/data/status_data/.git/")
20+
def xtl_clone(git2cpp_path):
21+
url = 'https://github.com/xtensor-stack/xtl.git'
22+
clone_working_dir = 'test/data'
23+
24+
clone_cmd = [git2cpp_path, 'clone', url]
25+
subprocess.run(clone_cmd, capture_output=True, cwd = clone_working_dir, text=True)
26+
2027
yield
21-
os.rename("test/data/status_data/.git/", "test/data/status_data/embedded_git/")
28+
29+
cleanup_cmd = ['rm', '-rf', 'xtl']
30+
subprocess.run(cleanup_cmd, capture_output=True, cwd = clone_working_dir, text=True)
31+
32+
@pytest.fixture
33+
def git_config(monkeypatch):
34+
monkeypatch.setenv("GIT_AUTHOR_NAME", "Jane Doe")
35+
monkeypatch.setenv("GIT_AUTHOR_EMAIL", "[email protected]")
36+
monkeypatch.setenv("GIT_COMMITTER_NAME", "Jane Doe")
37+
monkeypatch.setenv("GIT_COMMITTER_EMAIL", "[email protected]")

test/data/blank_file.txt

Whitespace-only changes.

test/data/status_data/embedded_git/COMMIT_EDITMSG

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/data/status_data/embedded_git/HEAD

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/data/status_data/embedded_git/config

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/data/status_data/embedded_git/description

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/data/status_data/embedded_git/hooks/applypatch-msg.sample

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/data/status_data/embedded_git/hooks/commit-msg.sample

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/data/status_data/embedded_git/hooks/fsmonitor-watchman.sample

Lines changed: 0 additions & 174 deletions
This file was deleted.

0 commit comments

Comments
 (0)