mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
write .makepkg.conf to home dir instead of repository root (#72)
This commit is contained in:
parent
2a07356d24
commit
e58ccdc8ad
@ -20,6 +20,7 @@
|
||||
import argparse
|
||||
|
||||
from pathlib import Path
|
||||
from pwd import getpwuid
|
||||
from typing import Type
|
||||
|
||||
from ahriman.application.application import Application
|
||||
@ -173,7 +174,9 @@ class Setup(Handler):
|
||||
packager(str): packager identifier (e.g. name, email)
|
||||
paths(RepositoryPaths): repository paths instance
|
||||
"""
|
||||
(paths.root / ".makepkg.conf").write_text(f"PACKAGER='{packager}'\n", encoding="utf8")
|
||||
uid, _ = paths.root_owner
|
||||
home_dir = Path(getpwuid(uid).pw_dir)
|
||||
(home_dir / ".makepkg.conf").write_text(f"PACKAGER='{packager}'\n", encoding="utf8")
|
||||
|
||||
@staticmethod
|
||||
def configuration_create_sudo(paths: RepositoryPaths, prefix: str, architecture: str) -> None:
|
||||
|
17
tests/ahriman/application/handlers/conftest.py
Normal file
17
tests/ahriman/application/handlers/conftest.py
Normal file
@ -0,0 +1,17 @@
|
||||
import pytest
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
_passwd = namedtuple("passwd", ["pw_dir"])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def passwd() -> _passwd:
|
||||
"""
|
||||
get passwd structure for the user
|
||||
|
||||
Returns:
|
||||
_passwd: passwd structure test instance
|
||||
"""
|
||||
return _passwd("home")
|
@ -3,6 +3,7 @@ import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from typing import Any
|
||||
from unittest import mock
|
||||
|
||||
from ahriman.application.handlers import Setup
|
||||
@ -130,15 +131,17 @@ def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, rep
|
||||
|
||||
|
||||
def test_configuration_create_makepkg(args: argparse.Namespace, repository_paths: RepositoryPaths,
|
||||
mocker: MockerFixture) -> None:
|
||||
passwd: Any, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create makepkg configuration
|
||||
"""
|
||||
args = _default_args(args)
|
||||
write_text_mock = mocker.patch("pathlib.Path.write_text")
|
||||
mocker.patch("ahriman.application.handlers.setup.getpwuid", return_value=passwd)
|
||||
write_text_mock = mocker.patch("pathlib.Path.write_text", autospec=True)
|
||||
|
||||
Setup.configuration_create_makepkg(args.packager, repository_paths)
|
||||
write_text_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), encoding="utf8")
|
||||
write_text_mock.assert_called_once_with(
|
||||
Path("home") / ".makepkg.conf", pytest.helpers.anyvar(str, True), encoding="utf8")
|
||||
|
||||
|
||||
def test_configuration_create_sudo(args: argparse.Namespace, repository_paths: RepositoryPaths,
|
||||
|
Loading…
Reference in New Issue
Block a user