Files
brencher/tests/test_cached_env.py
T

28 lines
954 B
Python

import pytest
from enironment import wrap_in_cached
from tests.test_remote_repo import RemoteRepoHelper
class TestCachedEnv:
"""Tests for the CachedEnv wrapper around GitEnv."""
def test_checkout_merged_empty_branches(self, repo_helper: RemoteRepoHelper) -> None:
"""Test CheckoutMerged with empty branches list - should fail"""
commit1 = repo_helper.create_commit(repo_helper.repo, "master", "master", "file1.txt", "content1",
"Initial commit")
repo_helper.env = wrap_in_cached(repo_helper.env)
repo_helper.env.branches = []
with pytest.raises(BaseException, match="Empty branches set"):
repo_helper.checkout_merged.progress()
repo_helper.env.branches = [('master', 'HEAD')]
result = repo_helper.checkout_merged.progress()
# Verify same auto branch is used with actual value checks
assert result.commit_hash == commit1.hexsha, f"Expected {commit1.hexsha}, got {result.commit_hash}"