Files
pkgmgr/tests/unit/pkgmgr/actions/install/installers/nix/test_result.py
Kevin Veen-Birkenbach 328203ccd7
Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / linter-shell (push) Has been cancelled
Mark stable commit / linter-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
**test(nix): add comprehensive unittest coverage for nix installer helpers**
* Add reusable fakes for runner and retry logic
* Cover conflict resolution paths (store-prefix, output-token, textual fallback)
* Add unit tests for profile parsing, normalization, matching, and text parsing
* Verify installer core behavior for success, mandatory failure, and optional failure
* Keep tests Nix-free using pure unittest + mocks

https://chatgpt.com/share/693efe80-d928-800f-98b7-0aaafee1d32a
2025-12-14 19:27:26 +01:00

30 lines
906 B
Python

from __future__ import annotations
import unittest
from pkgmgr.actions.install.installers.nix.profile.result import extract_stdout_text
class TestExtractStdoutText(unittest.TestCase):
def test_accepts_string(self) -> None:
self.assertEqual(extract_stdout_text("hello"), "hello")
def test_accepts_bytes(self) -> None:
self.assertEqual(extract_stdout_text(b"hi"), "hi")
def test_accepts_object_with_stdout_str(self) -> None:
class R:
stdout = "ok"
self.assertEqual(extract_stdout_text(R()), "ok")
def test_accepts_object_with_stdout_bytes(self) -> None:
class R:
stdout = b"ok"
self.assertEqual(extract_stdout_text(R()), "ok")
def test_fallback_str(self) -> None:
class R:
def __str__(self) -> str:
return "repr"
self.assertEqual(extract_stdout_text(R()), "repr")