Skip to content
Closed
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
1 change: 0 additions & 1 deletion app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

"""Fixtures for github runner image builder app."""


from pytest import Parser


Expand Down
1 change: 1 addition & 0 deletions app/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See LICENSE file for licensing details.

"""Fixtures for github runner image builder integration tests."""

import logging
import os
import secrets
Expand Down
6 changes: 2 additions & 4 deletions app/tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ def setup_aproxy(ssh_connection: SSHConnection, proxy: str) -> None:
proxy: The hostname and port in the format of "hostname:port".
"""
ssh_connection.run(f"/usr/bin/sudo snap set aproxy proxy={proxy} listen=:8444")
ssh_connection.run(
"""/usr/bin/sudo nft -f - << EOF
ssh_connection.run("""/usr/bin/sudo nft -f - << EOF
define default-ip = $(ip route get $(ip route show 0.0.0.0/0 | grep -oP 'via \\K\\S+') \
| grep -oP 'src \\K\\S+')
define private-ips = { 10.0.0.0/8, 127.0.0.1/8, 172.16.0.0/12, 192.168.0.0/16 }
Expand All @@ -400,8 +399,7 @@ def setup_aproxy(ssh_connection: SSHConnection, proxy: str) -> None:
}
}
EOF
"""
)
""")
# Wait for aproxy to become active.
for _ in range(6):
time.sleep(5)
Expand Down
1 change: 1 addition & 0 deletions app/tests/unit/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See LICENSE file for licensing details.

"""Unit tests for logging module."""

import logging as logging_module
from pathlib import Path
from unittest.mock import MagicMock
Expand Down
7 changes: 3 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# See LICENSE file for licensing details.

"""Entrypoint for GithubRunnerImageBuilder charm."""

import json
import logging

Expand Down Expand Up @@ -193,17 +194,15 @@ def _setup_builder(self) -> None:
def _setup_logrotate(self) -> None:
"""Set up the log rotation for image-builder application."""
APP_LOGROTATE_CONFIG_PATH.write_text(
dedent(
f"""\
dedent(f"""\
{str(LOG_FILE_PATH.absolute())} {{
weekly
rotate 3
compress
delaycompress
missingok
}}
"""
),
"""),
encoding="utf-8",
)
try:
Expand Down
1 change: 0 additions & 1 deletion src/pipx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

"""Module handling interactions with pipx."""


# Code is abstracting process interactions and is currently tested in integration tests.

import logging
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

"""Fixtures for github runner charm."""


from pytest import Parser


Expand Down
1 change: 1 addition & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See LICENSE file for licensing details.

"""Fixtures for github runner charm integration tests."""

import functools
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# See LICENSE file for licensing details.

"""Integration testing module."""

import json
import logging
from contextlib import asynccontextmanager
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ def test_install_clouds_yaml_not_exists(monkeypatch: pytest.MonkeyPatch, tmp_pat
)

contents = test_path.read_text(encoding="utf-8")
assert (
contents
== f"""clouds:
assert contents == f"""clouds:
test:
auth:
auth_url: test-url
Expand All @@ -267,7 +265,6 @@ def test_install_clouds_yaml_not_exists(monkeypatch: pytest.MonkeyPatch, tmp_pat
user_domain_name: test_domain
username: test-user
"""
)


def test_install_clouds_yaml_unchanged(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):
Expand Down Expand Up @@ -300,9 +297,7 @@ def test_install_clouds_yaml_unchanged(monkeypatch: pytest.MonkeyPatch, tmp_path
builder.install_clouds_yaml(cloud_config=test_config)

contents = test_path.read_text(encoding="utf-8")
assert (
contents
== f"""clouds:
assert contents == f"""clouds:
test:
auth:
auth_url: test-url
Expand All @@ -312,7 +307,6 @@ def test_install_clouds_yaml_unchanged(monkeypatch: pytest.MonkeyPatch, tmp_path
user_domain_name: test_domain
username: test-user
"""
)


@pytest.mark.parametrize(
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See LICENSE file for licensing details.

"""Unit tests for charm module."""

import secrets

# We're monkeypatching the subprocess module for testing
Expand Down
Loading