Skip to content

Commit 541052c

Browse files
authored
add reset test (#39)
1 parent 4ded7d1 commit 541052c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/subcommand/log_subcommand.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <CLI/CLI.hpp>
4-
#include <cstddef>
54
#include <limits>
65

76
#include "../utils/common.hpp"

test/test_reset.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import subprocess
2+
3+
import pytest
4+
5+
6+
def test_reset(xtl_clone, git_config, git2cpp_path, tmp_path, monkeypatch):
7+
assert (tmp_path / "xtl").exists()
8+
xtl_path = tmp_path / "xtl"
9+
10+
p = xtl_path / "mook_file.txt"
11+
p.write_text('')
12+
13+
cmd_add = [git2cpp_path, 'add', "mook_file.txt"]
14+
p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True)
15+
assert p_add.returncode == 0
16+
17+
cmd_commit = [git2cpp_path, 'commit', "-m", "test commit"]
18+
p_commit = subprocess.run(cmd_commit, cwd=xtl_path, text=True)
19+
assert p_commit.returncode == 0
20+
21+
cmd_log = [git2cpp_path, 'log']
22+
p_log = subprocess.run(cmd_log, capture_output=True, cwd=xtl_path, text=True)
23+
assert p_log.returncode == 0
24+
assert "Jane Doe" in p_log.stdout
25+
26+
cmd_reset = [git2cpp_path, "reset", "--hard", "HEAD~1"]
27+
p_reset = subprocess.run(cmd_reset, capture_output=True, cwd=xtl_path, text=True)
28+
assert p_reset.returncode == 0
29+
30+
cmd_log_2 = [git2cpp_path, 'log']
31+
p_log = subprocess.run(cmd_log_2, capture_output=True, cwd=xtl_path, text=True)
32+
assert p_log.returncode == 0
33+
assert "Jane Doe" not in p_log.stdout

0 commit comments

Comments
 (0)