Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add reset test
  • Loading branch information
SandrineP committed Aug 28, 2025
commit 4bbb5be09c99f101d975c8f469130c67a6d4c68e
1 change: 0 additions & 1 deletion src/subcommand/log_subcommand.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <CLI/CLI.hpp>
#include <cstddef>
#include <limits>

#include "../utils/common.hpp"
Expand Down
33 changes: 33 additions & 0 deletions test/test_reset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import subprocess

import pytest


def test_reset(xtl_clone, git_config, git2cpp_path, tmp_path, monkeypatch):
assert (tmp_path / "xtl").exists()
xtl_path = tmp_path / "xtl"

p = xtl_path / "mook_file.txt"
p.write_text('')

cmd_add = [git2cpp_path, 'add', "mook_file.txt"]
p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True)
assert p_add.returncode == 0

cmd_commit = [git2cpp_path, 'commit', "-m", "test commit"]
p_commit = subprocess.run(cmd_commit, cwd=xtl_path, text=True)
assert p_commit.returncode == 0

cmd_log = [git2cpp_path, 'log']
p_log = subprocess.run(cmd_log, capture_output=True, cwd=xtl_path, text=True)
assert p_log.returncode == 0
assert "Jane Doe" in p_log.stdout

cmd_reset = [git2cpp_path, "reset", "--hard", "HEAD~1"]
p_reset = subprocess.run(cmd_reset, capture_output=True, cwd=xtl_path, text=True)
assert p_reset.returncode == 0

cmd_log_2 = [git2cpp_path, 'log']
p_log = subprocess.run(cmd_log_2, capture_output=True, cwd=xtl_path, text=True)
assert p_log.returncode == 0
assert "Jane Doe" not in p_log.stdout